Re: [Qemu-devel] [PATCH buildfix] xenfb: Fix graphic_console_init() build failure

2014-03-08 Thread Peter Maydell
On 7 March 2014 21:42, Andreas Färber afaer...@suse.de wrote:
 In commit 5643706a095044d75df1c0588aac553a595b972b (console: add head
 to index to qemu consoles.) graphic_console_init() was extended to take
 an additional argument, but xenfb was not updated accordingly. Fix it.

 Cc: Gerd Hoffmann kra...@redhat.com
 Signed-off-by: Andreas Färber afaer...@suse.de

Applied to master, thanks. I've installed the xen dev libraries on
my build box, so I should be able to catch xen build failures
in future.

-- PMM



Re: [Qemu-devel] [PATCH] build: Fix installation of target-dependent files

2014-03-08 Thread Peter Maydell
On 20 January 2014 11:21, Lluís Vilanova vilan...@ac.upc.edu wrote:
 Pass all the relevant sub-directory make variables.

 Signed-off-by: Lluís Vilanova vilan...@ac.upc.edu
 ---
  Makefile |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to master as a build fix of sorts.

thanks
-- PMM



Re: [Qemu-devel] [PULL] migration patches

2014-03-08 Thread Peter Maydell
On 6 March 2014 20:03, Amit Shah amit.s...@redhat.com wrote:
 Hi Juan,

 Here's a compilation of migration-related patches from the list that
 I've reviewed.

 For the first patch, I picked Markus's over yours, just because it's
 been on the list longer.


 The following changes since commit 9fbee91a131a05e443d7108d7fbdf3ca91020290:

   Merge remote-tracking branch 'remotes/kvm/uq/master' into staging 
 (2014-02-27 16:00:31 +)

 are available in the git repository at:


   git://git.kernel.org/pub/scm/virt/qemu/amit/migration.git for-quintela

Just for clarity: I'm assuming from the salutation and the branch name
that you're expecting Juan to merge these into his tree; I'm not
going to apply them to master.

thanks
-- PMM



[Qemu-devel] test-qapi-visit causes clang -fsanitize=undefined warning

2014-03-08 Thread Peter Maydell
I've noticed that the tests/test-qapi-visit.c code provokes the following
complaint from clang's -fsanitize=undefined undefined-behaviour
checker when you run 'make check':

tests/test-qapi-visit.c:462:33: runtime error: member access within
null pointer of type 'UserDefA' (aka 'struct UserDefA')

which is the line
visit_type_bool(m, (*obj)-boolean, boolean, err);
in static void visit_type_UserDefA_fields(Visitor *m, UserDefA ** obj,
Error **errp).

It's presumably complaining because we've passed in an obj which
points to NULL (ie *obj == NULL). The callsite in visit_type_UserDefA()
checks for this and doesn't call the visit..fields function. The callsite
in visit_type_UserDefFlatUnion doesn't.

Unfortunately this is all autogenerated C so I'm not sure where exactly
the bug should be fixed. Could one of you have a look at it?

thanks
-- PMM



Re: [Qemu-devel] [PULL 00/19] Block patches

2014-03-08 Thread Peter Maydell
On 7 March 2014 13:32, Kevin Wolf kw...@redhat.com wrote:
 The following changes since commit f55ea6297cc0224fe4934b90ff5343b620b14669:

   block/gluster: Add missing argument to qemu_gluster_init() call (2014-03-04 
 20:20:57 +)

 are available in the git repository at:

   git://repo.or.cz/qemu/kevin.git tags/for-upstream

 for you to fetch changes up to 4089f7c6a0d91020ca60ce8300784c93dd9ddcbe:

   block: qemu-iotests 085 - live snapshots tests (2014-03-07 11:36:12 +0100)

 

Applied, thanks.

-- PMM



Re: [Qemu-devel] [PULL] migration patches

2014-03-08 Thread Juan Quintela
Peter Maydell peter.mayd...@linaro.org wrote:
 On 6 March 2014 20:03, Amit Shah amit.s...@redhat.com wrote:
 Hi Juan,

 Here's a compilation of migration-related patches from the list that
 I've reviewed.

 For the first patch, I picked Markus's over yours, just because it's
 been on the list longer.


 The following changes since commit 9fbee91a131a05e443d7108d7fbdf3ca91020290:

   Merge remote-tracking branch 'remotes/kvm/uq/master' into staging
 (2014-02-27 16:00:31 +)

 are available in the git repository at:


   git://git.kernel.org/pub/scm/virt/qemu/amit/migration.git for-quintela

 Just for clarity: I'm assuming from the salutation and the branch name
 that you're expecting Juan to merge these into his tree; I'm not
 going to apply them to master.

They are already on my last pull request.

Thanks to both, JUan.



Re: [Qemu-devel] [PULL] VirtFS update

2014-03-08 Thread Peter Maydell
On 7 March 2014 15:16, Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com wrote:
 Hi,

 Please pull the below update for VirtFS


 The following changes since commit d5001cf787ad0514839a81d0f2e771e01e076e21:

   xilinx: Delete hw/include/xilinx.h (2014-02-26 14:54:45 +1000)

 are available in the git repository at:

   https://github.com/kvaneesh/qemu.git for-upstream

 for you to fetch changes up to 993c91a0e996346c7ee8fa2ca310cc76edb59e17:

   hw/9pfs: Include virtio-9p-device.o in build (2014-03-04 09:20:49 +0530)

Applied, thanks.

-- PMM



Re: [Qemu-devel] [PULL 0/5] migration queue

2014-03-08 Thread Peter Maydell
On 8 March 2014 01:23, Juan Quintela quint...@redhat.com wrote:
 Hi

 Please pull

 - Fix missmerge of fwrite patch (armbru)
 - FIX XBZRLE crash: Gonglei
 - Add more traces for migration (Alexey)

 Especial thanks to Amit for getting the patches together.

I'm afraid this doesn't build for Windows:

/home/petmay01/linaro/qemu-for-merges/savevm.c:44:27: warning:
netinet/ether.h: No such file or directory
/home/petmay01/linaro/qemu-for-merges/savevm.c: In function
‘qemu_announce_self_iter’:
/home/petmay01/linaro/qemu-for-merges/savevm.c:85: warning: implicit
declaration of function ‘ether_ntoa’
/home/petmay01/linaro/qemu-for-merges/savevm.c:85: warning: nested
extern declaration of ‘ether_ntoa’
/home/petmay01/linaro/qemu-for-merges/savevm.c:86: warning: passing
argument 1 of ‘trace_qemu_announce_self_iter’ makes pointer from
integer without a cast
  CCalpha-softmmu/savevm.o
  LINK  alpha-softmmu/qemu-system-alpha.exe
savevm.o: In function `qemu_announce_self_iter':
/home/petmay01/linaro/qemu-for-merges/savevm.c:85: undefined reference
to `_ether_ntoa'
collect2: ld returned 1 exit status

thanks
-- PMM



Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 2/2] Fix return value of vga initlization on ppc

2014-03-08 Thread Alexey Kardashevskiy
On 03/07/2014 08:43 PM, Paolo Bonzini wrote:
 Il 07/03/2014 10:37, Mark Wu ha scritto:
 Before spapr_vga_init will returned false if the vga is specified by
 the command '-device VGA' because vga_interface_type was evaluated to
 VGA_NONE. With the change in previous patch of this series,
 spapr_vga_init should return true if it's told that the vga will be
 initialized in flow of the generic devices initialization.

 This patch also makes two cleanups:
 1. skip initialization for VGA_NONE
 2. remove the useless 'break'
 
 I think that after this patch, -nodefaults -device VGA will get a USB 
 controller that it didn't get before.


I suspect what was meant by the machine not aware of the graphics device
 is that the guest won't work with VGA and without keyboard (default
console will be vga + keyboard and not serial) which is USB and this is why
the patch is trying to add USB.


 
 Perhaps this in vl.c:
 
 bool usb_enabled(bool default_usb)
 {
 return qemu_opt_get_bool(qemu_get_machine_opts(), usb, default_usb);
 }
 
 should be
 
 bool usb_enabled(bool default_usb)
 {
 return qemu_opt_get_bool(qemu_get_machine_opts(), usb,
  !no_defaults  default_usb);
 }
 
 ?
 
 Thanks,
 
 Paolo
 
 Signed-off-by: Mark Wu wu...@linux.vnet.ibm.com
 ---
  hw/ppc/spapr.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

 diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
 index 93d02c1..4d0ac56 100644
 --- a/hw/ppc/spapr.c
 +++ b/hw/ppc/spapr.c
 @@ -765,13 +765,15 @@ static int spapr_vga_init(PCIBus *pci_bus)
  {
  switch (vga_interface_type) {
  case VGA_NONE:
 +return false;
 +case VGA_DEVICE:
 +return true;
  case VGA_STD:
  return pci_vga_init(pci_bus) != NULL;
  default:
  fprintf(stderr, This vga model is not supported,
  currently it only supports -vga std\n);
  exit(0);
 -break;
  }
  }
  

 
 


-- 
Alexey



Re: [Qemu-devel] [PATCH 4/5] hw/9pfs: use g_strdup_printf() instead of PATH_MAX limitation

2014-03-08 Thread Chen Gang
OK, thanks.

Next, I will/should continue to analyse the performance issue for 9pfs
when users drop into a long directory path under bash shell.

Although I am not quite sure, hope I can find the root cause within this
month (2014-03-31).

Welcome any suggestions, discussions, and completions for it.

Thanks.

On 03/07/2014 11:16 PM, Aneesh Kumar K.V wrote:
 From: Chen Gang gang.chen.5...@gmail.com
 
 When path is truncated by PATH_MAX limitation, it causes QEMU to access
 incorrect file. So use original full path instead of PATH_MAX within
 9pfs (need check/process ENOMEM for related memory allocation).
 
 The related test:
 
  - Environments (for qemu-devel):
 
- Host is under fedora17 desktop with ext4fs:
 
  qemu-system-x86_64 -hda test.img -m 1024 \
-net nic,vlan=4,model=virtio,macaddr=00:16:35:AF:94:04 \
-net tap,vlan=4,ifname=tap4,script=no,downscript=no \
-device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare \
-fsdev local,security_model=passthrough,id=fsdev0,\
  path=/upstream/vm/data/share/1234567890abcdefghijklmnopqrstuvwxyz\
ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890acdefghijklmnopqrstuvwxyz\
ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890/111\
\
\
2223\
33
 
 - Guest is ubuntu12 server with 9pfs.
 
   mount -t 9p -o trans=virtio,version=9p2000.L hostshare /share
 
 - Limitations:
 
   full path limitation is PATH_MAX (4096B include nul) under Linux.
   file/dir node name maximized length is 256 (include nul) under ext4.
 
  - Special test:
 
 Under host, modify the file: /upstream/vm/data/share/1234567890abcdefg\
   hijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890acdefghijklmno\
   pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890/1\
   11222\
   2\
   22233\
   3/444\
   4\
   4\
   444/5\
   5\
   5\
   5\
   /\
   6\
   6\
   6/777\
   7\
   7\
   777/8\
   8\
   8\
   8\
   8/999\
   9\
   9\
   9/000\
   0\
   0\
   /\
   a\
   a\
   a/bbb\
   b\
   b\
   bbb/c\
   c\
   c\
   c\
   cc/dd\
   

Re: [Qemu-devel] test-qapi-visit causes clang -fsanitize=undefined warning

2014-03-08 Thread Peter Maydell
On 8 March 2014 12:39, Peter Maydell peter.mayd...@linaro.org wrote:
 I've noticed that the tests/test-qapi-visit.c code provokes the following
 complaint from clang's -fsanitize=undefined undefined-behaviour
 checker when you run 'make check':

 tests/test-qapi-visit.c:462:33: runtime error: member access within
 null pointer of type 'UserDefA' (aka 'struct UserDefA')

There's also this clang compile warning which is probably not
related but is also in code dealing with unions:

  CCtests/test-qmp-output-visitor.o
/home/petmay01/linaro/qemu-for-merges/tests/test-qmp-output-visitor.c:452:17:
warning: implicit conversion from enumeration type
  'enum UserDefUnionKind' to different enumeration type
'UserDefFlatUnionKind' (aka 'enum UserDefFlatUnionKind')
  [-Wenum-conversion]
tmp-kind = USER_DEF_UNION_KIND_A;
  ~ ^
1 warning generated.

 thanks
 -- PMM



[Qemu-devel] test-qmp-commands reads freed memory

2014-03-08 Thread Peter Maydell
The test-qmp-commands test binary seems to read from freed
memory. This triggers the MacOSX malloc implementation's
assertions. git bisect blames

commit c2216a8a7a587e594f50bebbdf81fcf168444b68
Author: Markus Armbruster arm...@redhat.com
Date:   Sat Mar 1 08:40:29 2014 +0100

tests/qapi-schema: Cover simple argument types

Signed-off-by: Markus Armbruster arm...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
Signed-off-by: Luiz Capitulino lcapitul...@redhat.com

Valgrind will spot it:

cam-vm-266:precise:qemu$ valgrind build/x86/tests/test-qmp-commands
==15391== Memcheck, a memory error detector
==15391== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==15391== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==15391== Command: build/x86/tests/test-qmp-commands
==15391==
/0.15/dispatch_cmd: OK
/0.15/dispatch_cmd_error: OK
/0.15/dispatch_cmd_io: ==15391== Invalid read of size 8
==15391==at 0x1344F6: qobject_decref (qobject.h:97)
==15391==by 0x134FFD: test_dispatch_cmd_io (test-qmp-commands.c:144)
==15391==by 0x4E9A65A: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9A7D5: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9AB2A: g_test_run_suite (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x13540D: main (test-qmp-commands.c:229)
==15391==  Address 0x5ea26a8 is 8 bytes inside a block of size 4,120 free'd
==15391==at 0x4C2A82E: free (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15391==by 0x13B741: qdict_destroy_obj (qdict.c:477)
==15391==by 0x134580: qobject_decref (qobject.h:100)
==15391==by 0x134F41: test_dispatch_cmd_io (test-qmp-commands.c:136)
==15391==by 0x4E9A65A: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9A7D5: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9AB2A: g_test_run_suite (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x13540D: main (test-qmp-commands.c:229)
==15391==
==15391== Invalid write of size 8
==15391==at 0x134502: qobject_decref (qobject.h:97)
==15391==by 0x134FFD: test_dispatch_cmd_io (test-qmp-commands.c:144)
==15391==by 0x4E9A65A: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9A7D5: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9AB2A: g_test_run_suite (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x13540D: main (test-qmp-commands.c:229)
==15391==  Address 0x5ea26a8 is 8 bytes inside a block of size 4,120 free'd
==15391==at 0x4C2A82E: free (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15391==by 0x13B741: qdict_destroy_obj (qdict.c:477)
==15391==by 0x134580: qobject_decref (qobject.h:100)
==15391==by 0x134F41: test_dispatch_cmd_io (test-qmp-commands.c:136)
==15391==by 0x4E9A65A: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9A7D5: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9AB2A: g_test_run_suite (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x13540D: main (test-qmp-commands.c:229)
==15391==
==15391== Invalid read of size 8
==15391==at 0x13450A: qobject_decref (qobject.h:97)
==15391==by 0x134FFD: test_dispatch_cmd_io (test-qmp-commands.c:144)
==15391==by 0x4E9A65A: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9A7D5: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9AB2A: g_test_run_suite (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x13540D: main (test-qmp-commands.c:229)
==15391==  Address 0x5ea26a8 is 8 bytes inside a block of size 4,120 free'd
==15391==at 0x4C2A82E: free (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15391==by 0x13B741: qdict_destroy_obj (qdict.c:477)
==15391==by 0x134580: qobject_decref (qobject.h:100)
==15391==by 0x134F41: test_dispatch_cmd_io (test-qmp-commands.c:136)
==15391==by 0x4E9A65A: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9A7D5: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x4E9AB2A: g_test_run_suite (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==15391==by 0x13540D: main (test-qmp-commands.c:229)
==15391==
OK


thanks
-- PMM



[Qemu-devel] [Bug 1289788] [NEW] MIDI access (not only adlib) hangs WinNT on QEMU 1.7.x

2014-03-08 Thread TC1988
Public bug reported:

Windows NT 4.0 and 2000 (including the latest git release), when enabling adlib 
(with sb16 already enabled) or the built-in synth of the es1370, hang on QEMU 
1.7.x (also with 1.7.50) when they try to play MIDI files (like canyon.mid, 
etc). I have already tried bisecting but seems that this bug has been 
introduced sometime in 1.7.0's development time.
Screenshot attached: http://goput.it/ig2l.png

** Affects: qemu
 Importance: Undecided
 Status: New

** Description changed:

- Windows NT 4.0 and 2000 (including the latest git release), when
- enabling adlib (with sb16 already enabled) or the built-in synth of the
- es1370, hang on QEMU 1.7.x (also with 1.7.50) when they try to play MIDI
- files (like canyon.mid, etc). I have already tried bisecting but seems
- that this bug has been introduced sometime in 1.7.0's development time.
+ Windows NT 4.0 and 2000 (including the latest git release), when enabling 
adlib (with sb16 already enabled) or the built-in synth of the es1370, hang on 
QEMU 1.7.x (also with 1.7.50) when they try to play MIDI files (like 
canyon.mid, etc). I have already tried bisecting but seems that this bug has 
been introduced sometime in 1.7.0's development time.
+ Screenshot attached: http://goput.it/ig2l.png

** Summary changed:

- MIDI access (not only adlib) hangs WinNT on QEMU
+ MIDI access (not only adlib) hangs WinNT on QEMU 1.7.x

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

Title:
  MIDI access (not only adlib) hangs WinNT on QEMU 1.7.x

Status in QEMU:
  New

Bug description:
  Windows NT 4.0 and 2000 (including the latest git release), when enabling 
adlib (with sb16 already enabled) or the built-in synth of the es1370, hang on 
QEMU 1.7.x (also with 1.7.50) when they try to play MIDI files (like 
canyon.mid, etc). I have already tried bisecting but seems that this bug has 
been introduced sometime in 1.7.0's development time.
  Screenshot attached: http://goput.it/ig2l.png

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



[Qemu-devel] [PATCH] tap: avoid deadlocking rx

2014-03-08 Thread Stefan Hajnoczi
The net subsystem has a control flow mechanism so peer NetClientStates
can tell each other to stop sending packets.  This is used to stop
monitoring the tap file descriptor for incoming packets if the guest rx
ring has no spare buffers.

There is a corner case when tap_can_send() is true at the beginning of
an event loop iteration but becomes false before the tap_send() fd
handler is invoked.

tap_send() will read the packet from the tap file descriptor and attempt
to send it.  The net queue will hold on to the packet and return 0,
indicating that further I/O is not possible.  tap then stops monitoring
the file descriptor for reads.

This is unlike the normal case where tap_can_send() is the same before
and during the event loop iteration.  The event loop would simply not
monitor the file descriptor if tap_can_send() returns true.  Upon next
iteration it would check tap_can_send() again and begin monitoring if we
can send.

The deadlock happens because tap_send() explicitly disabled read_poll.
This is done with the expectation that the peer will call
qemu_net_queue_flush().  But hw/net/virtio-net.c does not monitor
vm_running transitions and issue the flush.  Hence we're left with a
broken tap device.

Cc: qemu-sta...@nongnu.org
Reported-by: Neil Skrypuch n...@tembosocial.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 net/tap.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/tap.c b/net/tap.c
index 2d5099b..8847ce1 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -190,7 +190,7 @@ static void tap_send(void *opaque)
 TAPState *s = opaque;
 int size;
 
-do {
+while (qemu_can_send_packet(s-nc)) {
 uint8_t *buf = s-buf;
 
 size = tap_read_packet(s-fd, s-buf, sizeof(s-buf));
@@ -206,8 +206,11 @@ static void tap_send(void *opaque)
 size = qemu_send_packet_async(s-nc, buf, size, tap_send_completed);
 if (size == 0) {
 tap_read_poll(s, false);
+break;
+} else if (size  0) {
+break;
 }
-} while (size  0  qemu_can_send_packet(s-nc));
+}
 }
 
 static bool tap_has_ufo(NetClientState *nc)
-- 
1.8.5.3




Re: [Qemu-devel] Live migration results in non-working virtio-net device (sometimes)

2014-03-08 Thread Stefan Hajnoczi
On Thu, Jan 30, 2014 at 7:23 PM, Neil Skrypuch n...@tembosocial.com wrote:
 As mentioned above I can reproduce this with minimal effort, and am willing to
 test out any patches or provide further details as necessary.

Hi Neil,
Thanks for all your efforts on IRC.  I have sent a fix titled [PATCH]
tap: avoid deadlocking rx.

If your tests pass with the fix, please respond to that email thread
with Tested-by: Neil Skrypuch n...@tembosocial.com.

Thanks,
Stefan



Re: [Qemu-devel] test-qmp-commands reads freed memory

2014-03-08 Thread Luiz Capitulino
On Sat, 8 Mar 2014 14:40:27 +
Peter Maydell peter.mayd...@linaro.org wrote:

 The test-qmp-commands test binary seems to read from freed
 memory. This triggers the MacOSX malloc implementation's
 assertions. git bisect blames

Can you try the patch below? For the clang ones, I'll have to install it etc,
so it will take a bit longer.

I wonder how this didn't explode...

diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
index 8e62c2d..554e222 100644
--- a/tests/test-qmp-commands.c
+++ b/tests/test-qmp-commands.c
@@ -141,7 +141,7 @@ static void test_dispatch_cmd_io(void)
 
 ret3 = qobject_to_qint(test_qmp_dispatch(req));
 assert(qint_get_int(ret3) == 66);
-QDECREF(ret);
+QDECREF(ret3);
 
 QDECREF(req);
 }



Re: [Qemu-devel] test-qmp-commands reads freed memory

2014-03-08 Thread Peter Maydell
On 8 March 2014 16:09, Luiz Capitulino lcapitul...@redhat.com wrote:
 On Sat, 8 Mar 2014 14:40:27 +
 Peter Maydell peter.mayd...@linaro.org wrote:

 The test-qmp-commands test binary seems to read from freed
 memory. This triggers the MacOSX malloc implementation's
 assertions. git bisect blames

 Can you try the patch below? For the clang ones, I'll have to install it etc,
 so it will take a bit longer.

 I wonder how this didn't explode...

 diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
 index 8e62c2d..554e222 100644
 --- a/tests/test-qmp-commands.c
 +++ b/tests/test-qmp-commands.c
 @@ -141,7 +141,7 @@ static void test_dispatch_cmd_io(void)

  ret3 = qobject_to_qint(test_qmp_dispatch(req));
  assert(qint_get_int(ret3) == 66);
 -QDECREF(ret);
 +QDECREF(ret3);

  QDECREF(req);
  }

Yep, seems to work (both MacOSX and valgrind are happier).

Tested-by: Peter Maydell peter.mayd...@linaro.org

-- PMM



[Qemu-devel] [PATCH] tests: test-qmp-commands: Fix double free

2014-03-08 Thread Luiz Capitulino
The ret variable is freed twice, but on the second time we actually want
to free ret3 instead. Don't know why this didn't explode.

Reported-by: Peter Maydell peter.mayd...@linaro.org
Tested-by: Peter Maydell peter.mayd...@linaro.org
Signed-off-by: Luiz Capitulino lcapitul...@redhat.com
---
 tests/test-qmp-commands.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
index 8e62c2d..554e222 100644
--- a/tests/test-qmp-commands.c
+++ b/tests/test-qmp-commands.c
@@ -141,7 +141,7 @@ static void test_dispatch_cmd_io(void)
 
 ret3 = qobject_to_qint(test_qmp_dispatch(req));
 assert(qint_get_int(ret3) == 66);
-QDECREF(ret);
+QDECREF(ret3);
 
 QDECREF(req);
 }
-- 
1.8.1.4




[Qemu-devel] [Bug 1289788] Re: MIDI access (not only adlib) hangs WinNT on QEMU 1.7.x

2014-03-08 Thread TC1988
** Tags added: 2000 4.0 adlib bug es1370 midi nt serious win200 windows
winvista winxp

** Description changed:

  Windows NT 4.0 and 2000 (including the latest git release), when enabling 
adlib (with sb16 already enabled) or the built-in synth of the es1370, hang on 
QEMU 1.7.x (also with 1.7.50) when they try to play MIDI files (like 
canyon.mid, etc). I have already tried bisecting but seems that this bug has 
been introduced sometime in 1.7.0's development time.
  Screenshot attached: http://goput.it/ig2l.png
+ 
+ OS Used: Windows 7 x64 Ultimate SP1
+ command-line used: qemu-system-i386w.exe -L pc-bios -m 64 -cpu pentium -drive 
file=vbent40.img,if=floppy,id=fda -drive 
file=vhd.vhd,if=ide,media=disk,bus=0,unit=0,id=harddisk0 -drive 
file=E:,if=ide,media=cdrom,bus=1,unit=0,id=cdrom -net nic,model=pcnet -net user 
-vga std -device ES1370 -boot menu=on -monitor 
telnet:127.0.0.1:,server,nowait

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

Title:
  MIDI access (not only adlib) hangs WinNT on QEMU 1.7.x

Status in QEMU:
  New

Bug description:
  Windows NT 4.0 and 2000 (including the latest git release), when enabling 
adlib (with sb16 already enabled) or the built-in synth of the es1370, hang on 
QEMU 1.7.x (also with 1.7.50) when they try to play MIDI files (like 
canyon.mid, etc). I have already tried bisecting but seems that this bug has 
been introduced sometime in 1.7.0's development time.
  Screenshot attached: http://goput.it/ig2l.png

  OS Used: Windows 7 x64 Ultimate SP1
  command-line used: qemu-system-i386w.exe -L pc-bios -m 64 -cpu pentium -drive 
file=vbent40.img,if=floppy,id=fda -drive 
file=vhd.vhd,if=ide,media=disk,bus=0,unit=0,id=harddisk0 -drive 
file=E:,if=ide,media=cdrom,bus=1,unit=0,id=cdrom -net nic,model=pcnet -net user 
-vga std -device ES1370 -boot menu=on -monitor 
telnet:127.0.0.1:,server,nowait

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



[Qemu-devel] [PATCH RFC 0/2] qemu-arg: general purpose argument parser

2014-03-08 Thread Leandro Dorileo
The following patchset introduces a general purpose argument parser and migrates
qemu-img to make use of it. qemu-img is just the first user of it, if we see a
good feedback here I move forward and migrate all the other possible users.

Leandro Dorileo (2):
  qemu-arg: introduce a general purpose argument parser
  qemu-img: migrate to use qemu-arg

 .gitignore  |1 +
 Makefile|   12 +-
 include/qemu/qemu-arg.h |  287 
 qemu-img-cmds.hx|   77 ---
 qemu-img-descs.h|  128 +
 qemu-img.c  | 1184 ---
 util/Makefile.objs  |1 +
 util/qemu-arg.c |  887 +++
 8 files changed, 1706 insertions(+), 871 deletions(-)
 create mode 100644 include/qemu/qemu-arg.h
 delete mode 100644 qemu-img-cmds.hx
 create mode 100644 qemu-img-descs.h
 create mode 100644 util/qemu-arg.c

-- 
1.9.0




[Qemu-devel] [PATCH RFC 1/2] qemu-arg: introduce a general purpose argument parser

2014-03-08 Thread Leandro Dorileo
qemu-arg defines a standardized API for argument parsing, help displaying and
texi generation/sync.

The implementation supports command + arguments form (i.e qemu-img requirements)
and a more general simple arguments parsing. So we can parse:

$ prog command --arg1 --arg2
$ prog --arg1 --arg2

We support the following:
   + basic arguments validation (i.e required arguments and required values);
   + basic arguments transformations (integer, bool values)
   + repeated/cumullated arguments (i.e -o opt1=val -o opt2=val2 will result 
the
 string opt1=val,opt2=val2)
   + positional arguments;
 + identified positional for fixed/defined numbers of expected positional 
args;
 + listed positional for N expected positional args;
   + help messages generation;
   + texi generation;
   + default value setting;
   + mutually exclusive arguments;
   + display and parsing decorated arguments (--argument value and 
--argument=value
  are valid)

Signed-off-by: Leandro Dorileo l...@dorileo.org
---
 include/qemu/qemu-arg.h | 287 
 util/Makefile.objs  |   1 +
 util/qemu-arg.c | 887 
 3 files changed, 1175 insertions(+)
 create mode 100644 include/qemu/qemu-arg.h
 create mode 100644 util/qemu-arg.c

diff --git a/include/qemu/qemu-arg.h b/include/qemu/qemu-arg.h
new file mode 100644
index 000..c8d8fb4
--- /dev/null
+++ b/include/qemu/qemu-arg.h
@@ -0,0 +1,287 @@
+/*
+ * QEMU argument helper
+ *
+ * Copyright (c) 2014 Leandro Dorileo l...@dorileo.org
+ *
+ * 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.
+ */
+
+#ifndef _QEMU_ARG_H_
+#define _QEMU_ARG_H_
+
+#include libintl.h
+#include stdbool.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+
+typedef struct _QemuArgContext QemuArgContext;
+typedef struct _QemuArgCommand QemuArgCommand;
+
+typedef enum _QemuArgOptType {
+QEMU_ARG_OPT_TYPE_INT,
+QEMU_ARG_OPT_TYPE_BOOL,
+QEMU_ARG_OPT_TYPE_STR,
+QEMU_ARG_OPT_TYPE_POSITIONAL,
+QEMU_ARG_OPT_TYPE_POSITIONAL_LIST,
+QEMU_ARG_OPT_TYPE_DEPRECATED,
+QEMU_ARG_OPT_TYPE_GROUP,
+QEMU_ARG_OPT_TYPE_SENTINEL,
+} QemuArgOptType;
+
+typedef struct _QemuArgIntValue {
+/** default value */
+int def_val;
+
+/** user value pointer */
+int *value;
+} QemuArgIntValue;
+
+typedef struct _QemuArgBoolValue {
+/** default value */
+bool def_val;
+
+/** user value pointer */
+bool *value;
+} QemuArgBoolValue;
+
+typedef struct _QemuArgStrValue {
+/** default value */
+char *def_val;
+
+/** user value pointer */
+char **value;
+} QemuArgStrValue;
+
+typedef struct _QemuArgStrListValue {
+/** default value */
+char **def_val;
+
+/** user value pointer */
+char ***value;
+
+/** list elements counter */
+int list_cnt;
+} QemuArgStrListValue;
+
+typedef enum _QemuArgOptFlag {
+ARG_FLAG_NONE   = 0,
+
+/** provide many arguments instances, their value are concatenated in a
+comman separated string */
+ARG_FLAG_CUMULATE   = 1  0,
+
+/** the argument is required */
+ARG_FLAG_REQUIRED   = 1  1,
+
+/** the argument requires a value like --foo bar where --foo requires bar 
*/
+ARG_FLAG_REQ_VALUE  = 1  2,
+} QemuArgOptFlag;
+
+typedef struct _QemuArgOpt {
+/** argument type, bool, int, str, etc @see QemuArgOptType */
+QemuArgOptType type;
+
+/** the argument's short name i.e -c */
+const char short_name;
+
+/** argument's long name i.e --cache */
+const char *long_name;
+
+/** argument's description, used to display a hint about the argument's
+value i.e -f fmt where fmt is the arg's desc */
+const char *desc;
+
+/** help message, describes the argument */
+const char *help;
+
+/** some behavior flags @see QemuArgOptFlag for possible modifiers */
+int flags;
+
+/** indicates the argument was set, for bool values it tells we got the
+

Re: [Qemu-devel] [PATCH RFC 0/2] qemu-arg: general purpose argument parser

2014-03-08 Thread Peter Maydell
On 8 March 2014 18:47, Leandro Dorileo l...@dorileo.org wrote:
 The following patchset introduces a general purpose argument parser and 
 migrates
 qemu-img to make use of it. qemu-img is just the first user of it, if we see a
 good feedback here I move forward and migrate all the other possible users.

Can you describe what the QEMU-specific features are that
mean we must roll our own argument-parsing infrastructure
rather than using (say) the glib option parsing routines?

thanks
-- PMM



Re: [Qemu-devel] [PATCH v4] target-sparc: Add and use CPU_FEATURE_CASA

2014-03-08 Thread Mark Cave-Ayland

On 14/02/14 16:06, Sebastian Huber wrote:


The LEON3 processor has support for the CASA instruction which is
normally only available for SPARC V9 processors.  Binutils 2.24
and GCC 4.9 will support this instruction for LEON3.  GCC uses it to
generate C11 atomic operations.

The CAS synthetic instruction uses an ASI of 0x80.  If TARGET_SPARC64 is
not defined use a supervisor data load/store for an ASI of 0x80 in
helper_ld_asi()/helper_st_asi().  The supervisor data load/store was
choosen according to the LEON3 documentation.

The ASI 0x80 is defined in the SPARC V9 manual, Table 12—Address Space
Identifiers (ASIs).  Here we have: 0x80, ASI_PRIMARY, Unrestricted
access, Primary address space.

Tested with the following program:

   #includeassert.h
   #includestdatomic.h

   void test(void)
   {
 atomic_int a;
 int e;
 _Bool b;

 atomic_store(a, 1);
 e = 1;
 b = atomic_compare_exchange_strong(a,e, 2);
 assert(b);
 assert(atomic_load(a) == 2);

 atomic_store(a, 3);
 e = 4;
 b = atomic_compare_exchange_strong(a,e, 5);
 assert(!b);
 assert(atomic_load(a) == 3);
   }

Tested also on a NGMP board with a LEON4 processor.

v4: Fix coding style.

Signed-off-by: Sebastian Hubersebastian.hu...@embedded-brains.de
Reviewed-by: Fabien Chouteauchout...@adacore.com
---
  target-sparc/cpu.c |3 +-
  target-sparc/cpu.h |4 ++-
  target-sparc/helper.h  |4 ++-
  target-sparc/ldst_helper.c |   28 ++--
  target-sparc/translate.c   |   49 ---
  5 files changed, 56 insertions(+), 32 deletions(-)

diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c
index e7f878e..5806e59 100644
--- a/target-sparc/cpu.c
+++ b/target-sparc/cpu.c
@@ -458,7 +458,8 @@ static const sparc_def_t sparc_defs[] = {
  .mmu_trcr_mask = 0x,
  .nwindows = 8,
  .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_TA0_SHUTDOWN |
-CPU_FEATURE_ASR17 | CPU_FEATURE_CACHE_CTRL | CPU_FEATURE_POWERDOWN,
+CPU_FEATURE_ASR17 | CPU_FEATURE_CACHE_CTRL | CPU_FEATURE_POWERDOWN |
+CPU_FEATURE_CASA,
  },
  #endif
  };
diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h
index c519063..2531cf9 100644
--- a/target-sparc/cpu.h
+++ b/target-sparc/cpu.h
@@ -271,12 +271,14 @@ typedef struct sparc_def_t {
  #define CPU_FEATURE_ASR17(1  15)
  #define CPU_FEATURE_CACHE_CTRL   (1  16)
  #define CPU_FEATURE_POWERDOWN(1  17)
+#define CPU_FEATURE_CASA (1  18)

  #ifndef TARGET_SPARC64
  #define CPU_DEFAULT_FEATURES (CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP |  \
CPU_FEATURE_MUL | CPU_FEATURE_DIV | \
CPU_FEATURE_FLUSH | CPU_FEATURE_FSQRT | \
-  CPU_FEATURE_FMUL | CPU_FEATURE_FSMULD)
+  CPU_FEATURE_FMUL | CPU_FEATURE_FSMULD | \
+  CPU_FEATURE_CASA)
  #else
  #define CPU_DEFAULT_FEATURES (CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP |  \
CPU_FEATURE_MUL | CPU_FEATURE_DIV | \
diff --git a/target-sparc/helper.h b/target-sparc/helper.h
index 2a771b2..cd8d3fa 100644
--- a/target-sparc/helper.h
+++ b/target-sparc/helper.h
@@ -22,7 +22,6 @@ DEF_HELPER_1(popc, tl, tl)
  DEF_HELPER_4(ldda_asi, void, env, tl, int, int)
  DEF_HELPER_5(ldf_asi, void, env, tl, int, int, int)
  DEF_HELPER_5(stf_asi, void, env, tl, int, int, int)
-DEF_HELPER_5(cas_asi, tl, env, tl, tl, tl, i32)
  DEF_HELPER_5(casx_asi, tl, env, tl, tl, tl, i32)
  DEF_HELPER_2(set_softint, void, env, i64)
  DEF_HELPER_2(clear_softint, void, env, i64)
@@ -31,6 +30,9 @@ DEF_HELPER_2(tick_set_count, void, ptr, i64)
  DEF_HELPER_1(tick_get_count, i64, ptr)
  DEF_HELPER_2(tick_set_limit, void, ptr, i64)
  #endif
+#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
+DEF_HELPER_5(cas_asi, tl, env, tl, tl, tl, i32)
+#endif
  DEF_HELPER_3(check_align, void, env, tl, i32)
  DEF_HELPER_1(debug, void, env)
  DEF_HELPER_1(save, void, env)
diff --git a/target-sparc/ldst_helper.c b/target-sparc/ldst_helper.c
index 92761ad..32491b4 100644
--- a/target-sparc/ldst_helper.c
+++ b/target-sparc/ldst_helper.c
@@ -584,6 +584,7 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong 
addr, int asi, int size,
  }
  break;
  case 0xb: /* Supervisor data access */
+case 0x80:
  switch (size) {
  case 1:
  ret = cpu_ldub_kernel(env, addr);
@@ -955,6 +956,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, 
uint64_t val, int asi,
  }
  break;
  case 0xb: /* Supervisor data access */
+case 0x80:
  switch (size) {
  case 1:
  cpu_stb_kernel(env, addr, val);
@@ -2232,33 +2234,35 @@ void helper_stf_asi(CPUSPARCState *env, target_ulong 
addr, int asi, int size,
  }
  }

-target_ulong helper_cas_asi(CPUSPARCState *env, target_ulong addr,
-

Re: [Qemu-devel] [PATCH RFC 0/2] qemu-arg: general purpose argument parser

2014-03-08 Thread Leandro Dorileo
Hi Peter,

On Sat, Mar 08, 2014 at 06:55:50PM +, Peter Maydell wrote:
 On 8 March 2014 18:47, Leandro Dorileo l...@dorileo.org wrote:
  The following patchset introduces a general purpose argument parser and 
  migrates
  qemu-img to make use of it. qemu-img is just the first user of it, if we 
  see a
  good feedback here I move forward and migrate all the other possible users.
 
 Can you describe what the QEMU-specific features are that
 mean we must roll our own argument-parsing infrastructure
 rather than using (say) the glib option parsing routines?


I don't think GOption will do the output I want and think to be the ideal for
qemu or specially to qemu-img.

GOption knows nothing about command, since qemu-img was my first target I
wanted something to handle its command schema. GOption will not show the users
the list of available commands neither show commands specific options, I wanted
the user to run qemu-img create -h and show the create command arguments 
(similar
to git output). GOption will not do that by default, of course we can wrap that
and have something similar.

GOption will not be able to list commands and their arguments so we can generate
the .hx file (see patch 02 in my series) or maybe the texi output and keep the
sync between the implemented commands, arguments and the textinfo stuffs.
GOption also doesn't know about the cumulative stuff - well I agree this last
one is not somethig to justify qemu-arg per se.

The command callbacks flow is also something GOption will not give us for free,
we would still need to know ourself about the available commands and their
callees.

As I said, my first target was qemu-img, but I ended up writing something more
generic to be used elsewhere.

Of course I could wrap GOption or getopt and handle all the corner cases but
parsing the arguments myself gave me more flexibility.

Regards...

-- 
Leandro Dorileo



Re: [Qemu-devel] [PATCH v4] target-sparc: Add and use CPU_FEATURE_CASA

2014-03-08 Thread Peter Maydell
On 8 March 2014 20:16, Mark Cave-Ayland mark.cave-ayl...@ilande.co.uk wrote:
 [0.00] TRAPLOG: TPC(null)
 [0.00]   \|/  \|/
 [0.00]   @'/ .. \`@
 [0.00]   /_| \__/ |_\
 [0.00]  \__U_/
 [0.00] swapper(0): TL1: FPU IEEE Exception [#1]

Hah, I'd forgotten about the ascii art in SPARC Linux panics.
Takes me back to when I used a SPARCstation 2 for real work :-)

thanks
-- PMM



Re: [Qemu-devel] [PATCH qom-cpu 0/6] cpu: Unifying features parsing

2014-03-08 Thread Mark Cave-Ayland

On 04/03/14 20:32, Andreas Färber wrote:


Am 04.03.2014 03:55, schrieb Andreas Färber:

Hello,

Prompted by Alexey's desire for tweakable PowerPCCPU properties but also by
Peter's wish for ARMCPU properties, this series sets out to align cpu_model
parsing across targets.

QemuOpts would've been nice to use, but on the one hand x86 and sparc use
QemuOpts-incompatible +foo and -foo syntax (which accumulate rather than apply
immediately) and on the other linux-user and bsd-user don't use QemuOpts at all.

The x86 implementation is closest to the proposed API, save for some laziness.
SPARC is brought in line. And as fallback for the remaining targets a new
implementation, derived from x86 but supporting only key=value format, is added.

To facilitate using this infrastructure, a generic CPU init function is created.

Only lightly tested. Available at:
git://github.com/afaerber/qemu-cpu.git qom-cpu-features.v1
https://github.com/afaerber/qemu-cpu/commits/qom-cpu-features.v1

Regards,
Andreas

Cc: Alexey Kardashevskiya...@ozlabs.ru
Cc: Peter Maydellpeter.mayd...@linaro.org
Cc: Anthony Liguorianth...@codemonkey.ws

Andreas Färber (6):
   cpu: Introduce CPUClass::parse_features() hook
   target-sparc: Use error_report() for CPU error reporting
   target-sparc: Implement CPUClass::parse_features() for SPARCCPU
   target-sparc: Defer SPARCCPU feature inference to QOM realize


Mark and Fabien, forgot to CC you: Could you take a look at the sparc
parts and give them some testing please?

The very latest version can be found on qom-cpu-ppc branch if necessary.

Thanks,
Andreas


Hi Andreas,

I've had a quick test of this branch, and while I don't tend to use CPU 
options that much, the parsing seems to work as I might expect from 
looking at the changes. I think any other snags if they exist can be 
picked up during pre-release testing so:


Tested-by: Mark Cave-Ayland mark.cave-ayl...@ilande.co.uk


ATB,

Mark.



[Qemu-devel] [PULL 0/4] migration queue

2014-03-08 Thread Juan Quintela
The following changes since commit f53f3d0a00b6df39ce8dfca942608e5b6a9a4f71:

  Merge remote-tracking branch 'remotes/kvaneesh/for-upstream' into staging 
(2014-03-08 12:38:43 +)

are available in the git repository at:


  git://github.com/juanquintela/qemu.git tags/migration/20140308-1

for you to fetch changes up to 464400f6a5583eafb466595add435a3a33ea980f:

  migration: extend section_start/end traces (2014-03-08 22:22:34 +0100)


migration/next for 20140308


Alexey Kardashevskiy (2):
  vl: add system_wakeup_request tracepoint
  migration: extend section_start/end traces

Gonglei (1):
  XBZRLE: Fix qemu crash when resize the xbzrle cache

Markus Armbruster (1):
  qemu_file: Fix mismerge of use fwrite() correctly

 arch_init.c  | 52 +---
 qemu-file.c  |  2 +-
 savevm.c | 12 ++--
 trace-events |  5 +++--
 vl.c |  2 ++
 5 files changed, 61 insertions(+), 12 deletions(-)



[Qemu-devel] [PATCH 1/4] XBZRLE: Fix qemu crash when resize the xbzrle cache

2014-03-08 Thread Juan Quintela
From: Gonglei arei.gong...@huawei.com

Resizing the xbzrle cache during migration causes qemu-crash,
because the main-thread and migration-thread modify the xbzrle
cache size concurrently without lock-protection.

Signed-off-by: ChenLiang chenlian...@huawei.com
Signed-off-by: Gonglei arei.gong...@huawei.com
Reviewed-by: Dr. David Alan Gilbert dgilb...@redhat.com
Signed-off-by: Juan Quintela quint...@redhat.com
---
 arch_init.c | 52 +---
 1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index fe17279..60c975d 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -164,8 +164,9 @@ static struct {
 uint8_t *encoded_buf;
 /* buffer for storing page content */
 uint8_t *current_buf;
-/* Cache for XBZRLE */
+/* Cache for XBZRLE, Protected by lock. */
 PageCache *cache;
+QemuMutex lock;
 } XBZRLE = {
 .encoded_buf = NULL,
 .current_buf = NULL,
@@ -174,16 +175,52 @@ static struct {
 /* buffer used for XBZRLE decoding */
 static uint8_t *xbzrle_decoded_buf;

+static void XBZRLE_cache_lock(void)
+{
+if (migrate_use_xbzrle())
+qemu_mutex_lock(XBZRLE.lock);
+}
+
+static void XBZRLE_cache_unlock(void)
+{
+if (migrate_use_xbzrle())
+qemu_mutex_unlock(XBZRLE.lock);
+}
+
 int64_t xbzrle_cache_resize(int64_t new_size)
 {
+PageCache *new_cache, *cache_to_free;
+
 if (new_size  TARGET_PAGE_SIZE) {
 return -1;
 }

+/* no need to lock, the current thread holds qemu big lock */
 if (XBZRLE.cache != NULL) {
-return cache_resize(XBZRLE.cache, new_size / TARGET_PAGE_SIZE) *
-TARGET_PAGE_SIZE;
+/* check XBZRLE.cache again later */
+if (pow2floor(new_size) == migrate_xbzrle_cache_size()) {
+return pow2floor(new_size);
+}
+new_cache = cache_init(new_size / TARGET_PAGE_SIZE,
+TARGET_PAGE_SIZE);
+if (!new_cache) {
+DPRINTF(Error creating cache\n);
+return -1;
+}
+
+XBZRLE_cache_lock();
+/* the XBZRLE.cache may have be destroyed, check it again */
+if (XBZRLE.cache != NULL) {
+cache_to_free = XBZRLE.cache;
+XBZRLE.cache = new_cache;
+} else {
+cache_to_free = new_cache;
+}
+XBZRLE_cache_unlock();
+
+cache_fini(cache_to_free);
 }
+
 return pow2floor(new_size);
 }

@@ -539,6 +576,8 @@ static int ram_save_block(QEMUFile *f, bool last_stage)
 ret = ram_control_save_page(f, block-offset,
offset, TARGET_PAGE_SIZE, bytes_sent);

+XBZRLE_cache_lock();
+
 current_addr = block-offset + offset;
 if (ret != RAM_SAVE_CONTROL_NOT_SUPP) {
 if (ret != RAM_SAVE_CONTROL_DELAYED) {
@@ -587,6 +626,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage)
 acct_info.norm_pages++;
 }

+XBZRLE_cache_unlock();
 /* if page is unmodified, continue to the next */
 if (bytes_sent  0) {
 last_sent_block = block;
@@ -654,6 +694,7 @@ static void migration_end(void)
 migration_bitmap = NULL;
 }

+XBZRLE_cache_lock();
 if (XBZRLE.cache) {
 cache_fini(XBZRLE.cache);
 g_free(XBZRLE.cache);
@@ -663,6 +704,7 @@ static void migration_end(void)
 XBZRLE.encoded_buf = NULL;
 XBZRLE.current_buf = NULL;
 }
+XBZRLE_cache_unlock();
 }

 static void ram_migration_cancel(void *opaque)
@@ -693,13 +735,17 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
 dirty_rate_high_cnt = 0;

 if (migrate_use_xbzrle()) {
+qemu_mutex_lock_iothread();
 XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() /
   TARGET_PAGE_SIZE,
   TARGET_PAGE_SIZE);
 if (!XBZRLE.cache) {
+qemu_mutex_unlock_iothread();
 DPRINTF(Error creating cache\n);
 return -1;
 }
+qemu_mutex_init(XBZRLE.lock);
+qemu_mutex_unlock_iothread();

 /* We prefer not to abort if there is no memory */
 XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE);
-- 
1.8.5.3




[Qemu-devel] [PATCH 2/4] qemu_file: Fix mismerge of use fwrite() correctly

2014-03-08 Thread Juan Quintela
From: Markus Armbruster arm...@redhat.com

Reviewers accepted v2 of the patch, but what got committed was v1,
with the R-bys for v2.  This is the v1-v2 followup fix.

[Amit:
 This fixes commit aded6539d983280212e08d09f14157b1cb4d58cc
]

Signed-off-by: Markus Armbruster arm...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
Reviewed-by: Amit Shah amit.s...@redhat.com
Signed-off-by: Amit Shah amit.s...@redhat.com
Signed-off-by: Juan Quintela quint...@redhat.com
---
 qemu-file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qemu-file.c b/qemu-file.c
index f074af1..e5ec798 100644
--- a/qemu-file.c
+++ b/qemu-file.c
@@ -105,7 +105,7 @@ static int stdio_put_buffer(void *opaque, const uint8_t 
*buf, int64_t pos,
 res = fwrite(buf, 1, size, s-stdio_file);

 if (res != size) {
-return -EIO;   /* fake errno value */
+return -errno;
 }
 return res;
 }
-- 
1.8.5.3




[Qemu-devel] [PATCH 3/4] vl: add system_wakeup_request tracepoint

2014-03-08 Thread Juan Quintela
From: Alexey Kardashevskiy a...@ozlabs.ru

It might be useful for tracing migration.

Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru
Signed-off-by: Amit Shah amit.s...@redhat.com
Signed-off-by: Juan Quintela quint...@redhat.com
---
 trace-events | 1 +
 vl.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/trace-events b/trace-events
index aec4202..466c27e 100644
--- a/trace-events
+++ b/trace-events
@@ -486,6 +486,7 @@ runstate_set(int new_state) new state %d
 g_malloc(size_t size, void *ptr) size %zu ptr %p
 g_realloc(void *ptr, size_t size, void *newptr) ptr %p size %zu newptr %p
 g_free(void *ptr) ptr %p
+system_wakeup_request(int reason) reason=%d

 # block/qcow2.c
 qcow2_writev_start_req(void *co, int64_t sector, int nb_sectors) co %p sector 
% PRIx64  nb_sectors %d
diff --git a/vl.c b/vl.c
index 41581c1..50693e6 100644
--- a/vl.c
+++ b/vl.c
@@ -1837,6 +1837,8 @@ void qemu_register_suspend_notifier(Notifier *notifier)

 void qemu_system_wakeup_request(WakeupReason reason)
 {
+trace_system_wakeup_request(reason);
+
 if (!runstate_check(RUN_STATE_SUSPENDED)) {
 return;
 }
-- 
1.8.5.3




[Qemu-devel] [PATCH 4/4] migration: extend section_start/end traces

2014-03-08 Thread Juan Quintela
From: Alexey Kardashevskiy a...@ozlabs.ru

This adds @idstr to savevm_section_start and savevm_section_end
tracepoints.

Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru
Signed-off-by: Amit Shah amit.s...@redhat.com
Signed-off-by: Juan Quintela quint...@redhat.com
---
 savevm.c | 12 ++--
 trace-events |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/savevm.c b/savevm.c
index 7329fc5..d094fbb 100644
--- a/savevm.c
+++ b/savevm.c
@@ -527,13 +527,13 @@ int qemu_savevm_state_iterate(QEMUFile *f)
 if (qemu_file_rate_limit(f)) {
 return 0;
 }
-trace_savevm_section_start();
+trace_savevm_section_start(se-idstr, se-section_id);
 /* Section type */
 qemu_put_byte(f, QEMU_VM_SECTION_PART);
 qemu_put_be32(f, se-section_id);

 ret = se-ops-save_live_iterate(f, se-opaque);
-trace_savevm_section_end(se-section_id);
+trace_savevm_section_end(se-idstr, se-section_id);

 if (ret  0) {
 qemu_file_set_error(f, ret);
@@ -565,13 +565,13 @@ void qemu_savevm_state_complete(QEMUFile *f)
 continue;
 }
 }
-trace_savevm_section_start();
+trace_savevm_section_start(se-idstr, se-section_id);
 /* Section type */
 qemu_put_byte(f, QEMU_VM_SECTION_END);
 qemu_put_be32(f, se-section_id);

 ret = se-ops-save_live_complete(f, se-opaque);
-trace_savevm_section_end(se-section_id);
+trace_savevm_section_end(se-idstr, se-section_id);
 if (ret  0) {
 qemu_file_set_error(f, ret);
 return;
@@ -584,7 +584,7 @@ void qemu_savevm_state_complete(QEMUFile *f)
 if ((!se-ops || !se-ops-save_state)  !se-vmsd) {
 continue;
 }
-trace_savevm_section_start();
+trace_savevm_section_start(se-idstr, se-section_id);
 /* Section type */
 qemu_put_byte(f, QEMU_VM_SECTION_FULL);
 qemu_put_be32(f, se-section_id);
@@ -598,7 +598,7 @@ void qemu_savevm_state_complete(QEMUFile *f)
 qemu_put_be32(f, se-version_id);

 vmstate_save(f, se);
-trace_savevm_section_end(se-section_id);
+trace_savevm_section_end(se-idstr, se-section_id);
 }

 qemu_put_byte(f, QEMU_VM_EOF);
diff --git a/trace-events b/trace-events
index 466c27e..002c260 100644
--- a/trace-events
+++ b/trace-events
@@ -1040,8 +1040,8 @@ vmware_scratch_write(uint32_t index, uint32_t value) 
index %d, value 0x%x
 vmware_setmode(uint32_t w, uint32_t h, uint32_t bpp) %dx%d @ %d bpp

 # savevm.c
-savevm_section_start(void) 
-savevm_section_end(unsigned int section_id) section_id %u
+savevm_section_start(const char *id, unsigned int section_id) %s, section_id 
%u
+savevm_section_end(const char *id, unsigned int section_id) %s, section_id %u

 # arch_init.c
 migration_bitmap_sync_start(void) 
-- 
1.8.5.3




[Qemu-devel] Commit 3ab193e66262e60e0ff74ac1ab5cff04412e83cb seems to break mouse wheel

2014-03-08 Thread BALATON Zoltan

Hello,

I've noticed that mouse wheel stopped working for me recently with the 
VMWare mouse driver. Bisecting gave this:


3ab193e66262e60e0ff74ac1ab5cff04412e83cb is the first bad commit
commit 3ab193e66262e60e0ff74ac1ab5cff04412e83cb
Author: Gerd Hoffmann kra...@redhat.com
Date:   Thu Nov 28 12:27:40 2013 +0100

input: mouse: switch sdl ui to new core

Signed-off-by: Gerd Hoffmann kra...@redhat.com

Regards,
Balaton Zoltan



[Qemu-devel] sdl mouse no longer works

2014-03-08 Thread Gabriel L. Somlo
Gerd,

After the latest pull, my sdl mouse no longer works. I've tried with
both OS X and Fedora 20 live. The latter (easier command line with
no out of tree dependencies) is started with the following command line:

bin/qemu-system-x86_64 -enable-kvm -m 2048 -machine q35 \
-usb -device usb-kbd -device usb-mouse \
-device ide-drive,bus=ide.2,drive=HDD \
-drive id=HDD,if=none,snapshot=on,file=Fedora-Live-Desktop-x86_64-20-1.iso \
-monitor stdio

After a git bisect I tracked it down to commit
3ab193e66262e60e0ff74ac1ab5cff04412e83cb (mouse: switch sdl ui to new
core).

Is my command line deprecated, or am I tickling some sort of bug ?

Thanks,
--Gabriel



Re: [Qemu-devel] QEMU: SMBIOS: Build full smbios tables

2014-03-08 Thread Gabriel L. Somlo
On Thu, Mar 06, 2014 at 06:04:32PM +0100, Laszlo Ersek wrote:
  What really convinced me to go for all this additional work was
  Laszlo's suggestion that this might help if/when we try to start
  trying to use UEFI/tianocore/ovmf instead of SeaBIOS.
 
 Let me be a bit more precise... :)
 
 Moving SMBIOS generation from SeaBIOS to qemu (similarly to ACPI) would
 benefit:
 - SeaBIOS (IIRC Kevin had implied his preference for this),
 - OVMF (no need to play catch-up field-wise),
 - other boot firmware.
 
 I think I didn't suggest using OVMF *instead of* SeaBIOS. :)

Sorry if I unintentionally misrepresented what you said, I was trying
to paraphrase precisely what you just said above :)

 In any case, I think if you can pull of this migration of SMBIOS tables,
 that would be a huge service to the community. I should have reviewed
 your series but it seemed hard, and I didn't have to look very far for
 other work :), so I postponed it. Then Gerd said please split it up
 into smaller patches, which I can only agree with! :)

I'll send the current set of seven patches, which basically replace
the way types 0 and 1 are handled with building full tables, and adds
the option to request that a type 2 table be built.

I'd like to get the rest of what SeaBIOS builds by default (types 3+)
in before the 2.0 freeze (BTW, how much longer do I have for that?),
but while I start hacking on that I figured I'd help you help me by
making it easy to review what I have so far... :)

Thanks again,
--Gabriel



[Qemu-devel] [PATCH 1/7] SMBIOS: Update all table definitions to smbios spec v2.3

2014-03-08 Thread Gabriel L. Somlo
Table definitions for types 4 and 17 are only up to v2.0,
so add fields specified in smbios v2.3, as expected (and
advertised) by the SeaBIOS smbios entry point structure.

Signed-off-by: Gabriel Somlo so...@cmu.edu
---
 include/hw/i386/smbios.h | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/hw/i386/smbios.h b/include/hw/i386/smbios.h
index 18fb970..de1da87 100644
--- a/include/hw/i386/smbios.h
+++ b/include/hw/i386/smbios.h
@@ -79,7 +79,7 @@ struct smbios_type_3 {
 // contained elements follow
 } QEMU_PACKED;
 
-/* SMBIOS type 4 - Processor Information (v2.0) */
+/* SMBIOS type 4 - Processor Information (v2.3) */
 struct smbios_type_4 {
 struct smbios_structure_header header;
 uint8_t socket_designation_str;
@@ -97,6 +97,10 @@ struct smbios_type_4 {
 uint16_t l1_cache_handle;
 uint16_t l2_cache_handle;
 uint16_t l3_cache_handle;
+uint8_t serial_number_str;
+uint8_t asset_tag_number_str;
+uint8_t part_number_str;
+
 } QEMU_PACKED;
 
 /* SMBIOS type 16 - Physical Memory Array
@@ -111,7 +115,7 @@ struct smbios_type_16 {
 uint16_t memory_error_information_handle;
 uint16_t number_of_memory_devices;
 } QEMU_PACKED;
-/* SMBIOS type 17 - Memory Device
+/* SMBIOS type 17 - Memory Device (v2.3)
  *   Associated with one type 19
  */
 struct smbios_type_17 {
@@ -127,6 +131,11 @@ struct smbios_type_17 {
 uint8_t bank_locator_str;
 uint8_t memory_type;
 uint16_t type_detail;
+uint16_t speed;
+uint8_t manufacturer_str;
+uint8_t serial_number_str;
+uint8_t asset_tag_number_str;
+uint8_t part_number_str;
 } QEMU_PACKED;
 
 /* SMBIOS type 19 - Memory Array Mapped Address */
-- 
1.8.1.4




[Qemu-devel] [PATCH 2/7] SMBIOS: Rename smbios_set_type1_defaults() for more general use

2014-03-08 Thread Gabriel L. Somlo
Subsequent patches will utilize this function to set defaults for
more smbios types than just type 1, so the function name should
reflect this.

Signed-off-by: Gabriel Somlo so...@cmu.edu
---
 hw/i386/pc_piix.c| 12 ++--
 hw/i386/pc_q35.c |  8 
 hw/i386/smbios.c |  4 ++--
 include/hw/i386/smbios.h |  4 ++--
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index ae1699d..ef2d062 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -60,7 +60,7 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
 
 static bool has_pci_info;
 static bool has_acpi_build = true;
-static bool smbios_type1_defaults = true;
+static bool smbios_defaults = true;
 /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
  * host addresses aligned at 1Gbyte boundaries.  This way we can use 1GByte
  * pages in the host.
@@ -143,9 +143,9 @@ static void pc_init1(QEMUMachineInitArgs *args,
 guest_info-has_pci_info = has_pci_info;
 guest_info-isapc_ram_fw = !pci_enabled;
 
-if (smbios_type1_defaults) {
+if (smbios_defaults) {
 /* These values are guest ABI, do not change */
-smbios_set_type1_defaults(QEMU, Standard PC (i440FX + PIIX, 1996),
+smbios_set_defaults(QEMU, Standard PC (i440FX + PIIX, 1996),
   args-machine-name);
 }
 
@@ -264,7 +264,7 @@ static void pc_init_pci(QEMUMachineInitArgs *args)
 
 static void pc_compat_1_7(QEMUMachineInitArgs *args)
 {
-smbios_type1_defaults = false;
+smbios_defaults = false;
 gigabyte_align = false;
 }
 
@@ -343,7 +343,7 @@ static void pc_init_pci_no_kvmclock(QEMUMachineInitArgs 
*args)
 {
 has_pci_info = false;
 has_acpi_build = false;
-smbios_type1_defaults = false;
+smbios_defaults = false;
 disable_kvm_pv_eoi();
 enable_compat_apic_id_mode();
 pc_init1(args, 1, 0);
@@ -353,7 +353,7 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
 {
 has_pci_info = false;
 has_acpi_build = false;
-smbios_type1_defaults = false;
+smbios_defaults = false;
 if (!args-cpu_model) {
 args-cpu_model = 486;
 }
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index a7f6260..dfcc252 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -50,7 +50,7 @@
 
 static bool has_pci_info;
 static bool has_acpi_build = true;
-static bool smbios_type1_defaults = true;
+static bool smbios_defaults = true;
 /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
  * host addresses aligned at 1Gbyte boundaries.  This way we can use 1GByte
  * pages in the host.
@@ -130,9 +130,9 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
 guest_info-isapc_ram_fw = false;
 guest_info-has_acpi_build = has_acpi_build;
 
-if (smbios_type1_defaults) {
+if (smbios_defaults) {
 /* These values are guest ABI, do not change */
-smbios_set_type1_defaults(QEMU, Standard PC (Q35 + ICH9, 2009),
+smbios_set_defaults(QEMU, Standard PC (Q35 + ICH9, 2009),
   args-machine-name);
 }
 
@@ -242,7 +242,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
 
 static void pc_compat_1_7(QEMUMachineInitArgs *args)
 {
-smbios_type1_defaults = false;
+smbios_defaults = false;
 gigabyte_align = false;
 }
 
diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index e8f41ad..89dc070 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -256,8 +256,8 @@ static void smbios_build_type_1_fields(void)
 }
 }
 
-void smbios_set_type1_defaults(const char *manufacturer,
-   const char *product, const char *version)
+void smbios_set_defaults(const char *manufacturer,
+ const char *product, const char *version)
 {
 if (!type1.manufacturer) {
 type1.manufacturer = manufacturer;
diff --git a/include/hw/i386/smbios.h b/include/hw/i386/smbios.h
index de1da87..a7ec973 100644
--- a/include/hw/i386/smbios.h
+++ b/include/hw/i386/smbios.h
@@ -16,8 +16,8 @@
 #include qemu/option.h
 
 void smbios_entry_add(QemuOpts *opts);
-void smbios_set_type1_defaults(const char *manufacturer,
-   const char *product, const char *version);
+void smbios_set_defaults(const char *manufacturer,
+ const char *product, const char *version);
 uint8_t *smbios_get_table(size_t *length);
 
 /*
-- 
1.8.1.4




[Qemu-devel] [PATCH 3/7] SMBIOS: Streamline setting smbios defaults with macro

2014-03-08 Thread Gabriel L. Somlo
The function smbios_set_defaults() uses a repeating code pattern
for each field. This patch replaces that pattern with a macro.

Signed-off-by: Gabriel Somlo so...@cmu.edu
---
 hw/i386/smbios.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index 89dc070..f4ee7b4 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -256,18 +256,17 @@ static void smbios_build_type_1_fields(void)
 }
 }
 
+#define SMBIOS_SET_DEFAULT(field, value)  \
+if (!field) { \
+field = value;\
+}
+
 void smbios_set_defaults(const char *manufacturer,
  const char *product, const char *version)
 {
-if (!type1.manufacturer) {
-type1.manufacturer = manufacturer;
-}
-if (!type1.product) {
-type1.product = product;
-}
-if (!type1.version) {
-type1.version = version;
-}
+SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
+SMBIOS_SET_DEFAULT(type1.product, product);
+SMBIOS_SET_DEFAULT(type1.version, version);
 }
 
 uint8_t *smbios_get_table(size_t *length)
-- 
1.8.1.4




[Qemu-devel] [PATCH 4/7] SMBIOS: Replace type collision check mechanism with bitmaps

2014-03-08 Thread Gabriel L. Somlo
Replace existing smbios_check_collision() functionality with
a pair of bitmaps: have_binfile_bitmap and have_fields_bitmap.
Bits corresponding to each smbios type are set by smbios_entry_add(),
which also uses the bitmaps to ensure that binary blobs and field
values are never accepted for the same type.

These bitmaps will also be used in the future to decide whether
or not to build a full table for a given smbios type.

Signed-off-by: Gabriel Somlo so...@cmu.edu
---
 hw/i386/smbios.c | 51 
 include/hw/i386/smbios.h |  2 ++
 2 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index f4ee7b4..6889332 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -49,11 +49,8 @@ static size_t smbios_entries_len;
 static int smbios_type4_count = 0;
 static bool smbios_immutable;
 
-static struct {
-bool seen;
-int headertype;
-Location loc;
-} first_opt[2];
+static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1);
+static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1);
 
 static struct {
 const char *vendor, *version, *date;
@@ -164,29 +161,6 @@ static void smbios_validate_table(void)
 }
 }
 
-/*
- * To avoid unresolvable overlaps in data, don't allow both
- * tables and fields for the same smbios type.
- */
-static void smbios_check_collision(int type, int entry)
-{
-if (type  ARRAY_SIZE(first_opt)) {
-if (first_opt[type].seen) {
-if (first_opt[type].headertype != entry) {
-error_report(Can't mix file= and type= for same type);
-loc_push_restore(first_opt[type].loc);
-error_report(This is the conflicting setting);
-loc_pop(first_opt[type].loc);
-exit(1);
-}
-} else {
-first_opt[type].seen = true;
-first_opt[type].headertype = entry;
-loc_save(first_opt[type].loc);
-}
-}
-}
-
 static void smbios_add_field(int type, int offset, const void *data, size_t 
len)
 {
 struct smbios_field *field;
@@ -331,7 +305,14 @@ void smbios_entry_add(QemuOpts *opts)
 }
 
 header = (struct smbios_structure_header *)(table-data);
-smbios_check_collision(header-type, SMBIOS_TABLE_ENTRY);
+
+if (test_bit(header-type, have_fields_bitmap)) {
+error_report(Can't add binary type %d table! 
+ (fields already specified), header-type);
+exit(1);
+}
+set_bit(header-type, have_binfile_bitmap);
+
 if (header-type == 4) {
 smbios_type4_count++;
 }
@@ -346,7 +327,17 @@ void smbios_entry_add(QemuOpts *opts)
 if (val) {
 unsigned long type = strtoul(val, NULL, 0);
 
-smbios_check_collision(type, SMBIOS_FIELD_ENTRY);
+if (type  SMBIOS_MAX_TYPE) {
+error_report(smbios type (%ld) out of range!, type);
+exit(1);
+}
+
+if (test_bit(type, have_binfile_bitmap)) {
+error_report(Can't add fields for type %ld table! 
+ (binary file already loaded), type);
+exit(1);
+}
+set_bit(type, have_fields_bitmap);
 
 switch (type) {
 case 0:
diff --git a/include/hw/i386/smbios.h b/include/hw/i386/smbios.h
index a7ec973..8b63441 100644
--- a/include/hw/i386/smbios.h
+++ b/include/hw/i386/smbios.h
@@ -15,6 +15,8 @@
 
 #include qemu/option.h
 
+#define SMBIOS_MAX_TYPE 127
+
 void smbios_entry_add(QemuOpts *opts);
 void smbios_set_defaults(const char *manufacturer,
  const char *product, const char *version);
-- 
1.8.1.4




[Qemu-devel] [PATCH 5/7] SMBIOS: Add code to build full smbios tables

2014-03-08 Thread Gabriel L. Somlo
This patch adds a set of macros which build full smbios tables
of a given type, including the logic to decide whether a given
table type should be built or not.

To illustrate this new functionality, we introduce and optionally
build a table of type 2 (base board), which is required by some
versions of OS X (10.7 and 10.8).

Signed-off-by: Gabriel Somlo so...@cmu.edu
---
 hw/i386/smbios.c | 158 +++
 include/hw/i386/smbios.h |  16 +
 2 files changed, 174 insertions(+)

diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index 6889332..9679e06 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -48,6 +48,7 @@ static uint8_t *smbios_entries;
 static size_t smbios_entries_len;
 static int smbios_type4_count = 0;
 static bool smbios_immutable;
+static bool smbios_build_tables;
 
 static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1);
 static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1);
@@ -63,6 +64,10 @@ static struct {
 /* uuid is in qemu_uuid[] */
 } type1;
 
+static struct {
+const char *manufacturer, *product, *version, *serial, *asset, *location;
+} type2;
+
 static QemuOptsList qemu_smbios_opts = {
 .name = smbios,
 .head = QTAILQ_HEAD_INITIALIZER(qemu_smbios_opts.head),
@@ -146,6 +151,39 @@ static const QemuOptDesc qemu_smbios_type1_opts[] = {
 { /* end of list */ }
 };
 
+static const QemuOptDesc qemu_smbios_type2_opts[] = {
+{
+.name = type,
+.type = QEMU_OPT_NUMBER,
+.help = SMBIOS element type,
+},{
+.name = manufacturer,
+.type = QEMU_OPT_STRING,
+.help = manufacturer name,
+},{
+.name = product,
+.type = QEMU_OPT_STRING,
+.help = product name,
+},{
+.name = version,
+.type = QEMU_OPT_STRING,
+.help = version number,
+},{
+.name = serial,
+.type = QEMU_OPT_STRING,
+.help = serial number,
+},{
+.name = asset,
+.type = QEMU_OPT_STRING,
+.help = asset tag number,
+},{
+.name = location,
+.type = QEMU_OPT_STRING,
+.help = location in chassis,
+},
+{ /* end of list */ }
+};
+
 static void smbios_register_config(void)
 {
 qemu_add_opts(qemu_smbios_opts);
@@ -161,6 +199,90 @@ static void smbios_validate_table(void)
 }
 }
 
+static bool smbios_skip_table(uint8_t type, bool required_table)
+{
+if (test_bit(type, have_binfile_bitmap)) {
+return true; /* user provided their own binary blob(s) */
+}
+if (test_bit(type, have_fields_bitmap)) {
+return false; /* user provided fields via command line */
+}
+if (smbios_build_tables  required_table) {
+return false; /* we're building tables, and this one's required */
+}
+return true;
+}
+
+#define SMBIOS_BUILD_TABLE_PRE(tbl_type, tbl_handle, tbl_required)\
+struct smbios_table *w;   \
+struct smbios_type_##tbl_type *t; \
+size_t w_off, t_off; /* wrapper, table offsets into smbios_entries */ \
+int str_index = 0;\
+do {  \
+/* should we skip building this table ? */\
+if (smbios_skip_table(tbl_type, tbl_required)) {  \
+return;   \
+} \
+  \
+/* initialize fw_cfg smbios element count */  \
+if (!smbios_entries) {\
+smbios_entries_len = sizeof(uint16_t);\
+smbios_entries = g_malloc0(smbios_entries_len);   \
+} \
+  \
+/* use offsets of wrapper w and table t within smbios_entries  */ \
+/* (pointers must be updated after each realloc)   */ \
+w_off = smbios_entries_len;   \
+t_off = w_off + sizeof(*w);   \
+smbios_entries_len = t_off + sizeof(*t);  \
+smbios_entries = g_realloc(smbios_entries, smbios_entries_len);   \
+w = (struct smbios_table *)(smbios_entries + w_off);  \
+t = (struct smbios_type_##tbl_type *)(smbios_entries + t_off);\
+  \
+w-header.type = SMBIOS_TABLE_ENTRY;  \
+w-header.length = sizeof(*w) + sizeof(*t);   \
+

[Qemu-devel] [PATCH 6/7] SMBIOS: Build full tables for types 0 and 1

2014-03-08 Thread Gabriel L. Somlo
If defaults are set by piix or q35, or fields are given on the
command line, build full smbios tables for types 0 and 1 instead
of sending individual fields to the BIOS via fw_cfg.

Signed-off-by: Gabriel Somlo so...@cmu.edu
---
 hw/i386/smbios.c | 63 
 1 file changed, 63 insertions(+)

diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index 9679e06..e7df372 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -352,6 +352,62 @@ static void smbios_build_type_1_fields(void)
 }
 }
 
+static void smbios_build_type_0_table(void)
+{
+SMBIOS_BUILD_TABLE_PRE(0, 0x000, true); /* required */
+
+SMBIOS_TABLE_SET_STR(0, vendor_str, type0.vendor);
+SMBIOS_TABLE_SET_STR(0, bios_version_str, type0.version);
+
+t-bios_starting_address_segment = 0xE800; /* hardcoded in SeaBIOS */
+
+SMBIOS_TABLE_SET_STR(0, bios_release_date_str, type0.date);
+
+t-bios_rom_size = 0; /* hardcoded in SeaBIOS with FIXME comment */
+
+/* BIOS characteristics not supported */
+memset(t-bios_characteristics, 0, 8);
+t-bios_characteristics[0] = 0x08;
+
+/* Enable targeted content distribution (needed for SVVP, per SeaBIOS) */
+t-bios_characteristics_extension_bytes[0] = 0;
+t-bios_characteristics_extension_bytes[1] = 4;
+
+if (type0.have_major_minor) {
+t-system_bios_major_release = type0.major;
+t-system_bios_minor_release = type0.minor;
+} else {
+t-system_bios_major_release = 0;
+t-system_bios_minor_release = 0;
+}
+
+/* hardcoded in SeaBIOS */
+t-embedded_controller_major_release = 0xFF;
+t-embedded_controller_minor_release = 0xFF;
+
+SMBIOS_BUILD_TABLE_POST;
+}
+
+static void smbios_build_type_1_table(void)
+{
+SMBIOS_BUILD_TABLE_PRE(1, 0x100, true); /* required */
+
+SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer);
+SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product);
+SMBIOS_TABLE_SET_STR(1, version_str, type1.version);
+SMBIOS_TABLE_SET_STR(1, serial_number_str, type1.serial);
+if (qemu_uuid_set) {
+memcpy(t-uuid, qemu_uuid, 16);
+} else {
+memset(t-uuid, 0, 16);
+}
+t-wake_up_type = 0x06; /* power switch */
+SMBIOS_TABLE_SET_STR(1, sku_number_str, type1.sku);
+SMBIOS_TABLE_SET_STR(1, family_str, type1.family);
+
+SMBIOS_BUILD_TABLE_POST;
+}
+
 static void smbios_build_type_2_table(void)
 {
 SMBIOS_BUILD_TABLE_PRE(2, 0x200, false); /* optional */
@@ -379,6 +435,9 @@ void smbios_set_defaults(const char *manufacturer,
  const char *product, const char *version)
 {
 smbios_build_tables = true;
+SMBIOS_SET_DEFAULT(type0.vendor, manufacturer);
+SMBIOS_SET_DEFAULT(type0.version, version);
+SMBIOS_SET_DEFAULT(type0.date, 01/01/2014);
 SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
 SMBIOS_SET_DEFAULT(type1.product, product);
 SMBIOS_SET_DEFAULT(type1.version, version);
@@ -390,9 +449,13 @@ void smbios_set_defaults(const char *manufacturer,
 uint8_t *smbios_get_table(size_t *length)
 {
 if (!smbios_immutable) {
+smbios_build_type_0_table();
+smbios_build_type_1_table();
 smbios_build_type_2_table();
+if (false) { /* shut up gcc until we remove deprecated code */
 smbios_build_type_0_fields();
 smbios_build_type_1_fields();
+}
 smbios_validate_table();
 smbios_immutable = true;
 }
-- 
1.8.1.4




[Qemu-devel] [PATCH 7/7] SMBIOS: Remove unused code for passing individual fields to bios

2014-03-08 Thread Gabriel L. Somlo
This patch removes smbios_add_field() and the old code to insert
individual fields for types 0 and 1 into fw_cfg.

Signed-off-by: Gabriel Somlo so...@cmu.edu
---
 hw/i386/smbios.c | 80 
 1 file changed, 80 deletions(-)

diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index e7df372..54ad3e7 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -29,13 +29,6 @@ struct smbios_header {
 uint8_t type;
 } QEMU_PACKED;
 
-struct smbios_field {
-struct smbios_header header;
-uint8_t type;
-uint16_t offset;
-uint8_t data[];
-} QEMU_PACKED;
-
 struct smbios_table {
 struct smbios_header header;
 uint8_t data[];
@@ -283,75 +276,6 @@ static bool smbios_skip_table(uint8_t type, bool 
required_table)
 *(uint16_t *)smbios_entries += 1; \
 } while (0)
 
-static void smbios_add_field(int type, int offset, const void *data, size_t 
len)
-{
-struct smbios_field *field;
-
-if (!smbios_entries) {
-smbios_entries_len = sizeof(uint16_t);
-smbios_entries = g_malloc0(smbios_entries_len);
-}
-smbios_entries = g_realloc(smbios_entries, smbios_entries_len +
-  sizeof(*field) + len);
-field = (struct smbios_field *)(smbios_entries + smbios_entries_len);
-field-header.type = SMBIOS_FIELD_ENTRY;
-field-header.length = cpu_to_le16(sizeof(*field) + len);
-
-field-type = type;
-field-offset = cpu_to_le16(offset);
-memcpy(field-data, data, len);
-
-smbios_entries_len += sizeof(*field) + len;
-(*(uint16_t *)smbios_entries) =
-cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1);
-}
-
-static void smbios_maybe_add_str(int type, int offset, const char *data)
-{
-if (data) {
-smbios_add_field(type, offset, data, strlen(data) + 1);
-}
-}
-
-static void smbios_build_type_0_fields(void)
-{
-smbios_maybe_add_str(0, offsetof(struct smbios_type_0, vendor_str),
- type0.vendor);
-smbios_maybe_add_str(0, offsetof(struct smbios_type_0, bios_version_str),
- type0.version);
-smbios_maybe_add_str(0, offsetof(struct smbios_type_0,
- bios_release_date_str),
- type0.date);
-if (type0.have_major_minor) {
-smbios_add_field(0, offsetof(struct smbios_type_0,
- system_bios_major_release),
- type0.major, 1);
-smbios_add_field(0, offsetof(struct smbios_type_0,
- system_bios_minor_release),
- type0.minor, 1);
-}
-}
-
-static void smbios_build_type_1_fields(void)
-{
-smbios_maybe_add_str(1, offsetof(struct smbios_type_1, manufacturer_str),
- type1.manufacturer);
-smbios_maybe_add_str(1, offsetof(struct smbios_type_1, product_name_str),
- type1.product);
-smbios_maybe_add_str(1, offsetof(struct smbios_type_1, version_str),
- type1.version);
-smbios_maybe_add_str(1, offsetof(struct smbios_type_1, serial_number_str),
- type1.serial);
-smbios_maybe_add_str(1, offsetof(struct smbios_type_1, sku_number_str),
- type1.sku);
-smbios_maybe_add_str(1, offsetof(struct smbios_type_1, family_str),
- type1.family);
-if (qemu_uuid_set) {
-smbios_add_field(1, offsetof(struct smbios_type_1, uuid),
- qemu_uuid, 16);
-}
-}
-
 static void smbios_build_type_0_table(void)
 {
 SMBIOS_BUILD_TABLE_PRE(0, 0x000, true); /* required */
@@ -452,10 +376,6 @@ uint8_t *smbios_get_table(size_t *length)
 smbios_build_type_0_table();
 smbios_build_type_1_table();
 smbios_build_type_2_table();
-if (false) { /* shut up gcc until we remove deprecated code */
-smbios_build_type_0_fields();
-smbios_build_type_1_fields();
-}
 smbios_validate_table();
 smbios_immutable = true;
 }
-- 
1.8.1.4




[Qemu-devel] [PULL 00/10] tcg/aarch64 cleanups, part 1

2014-03-08 Thread Richard Henderson
Recently reviewed.  Part 2 to be posted shortly.


r~


The following changes since commit f53f3d0a00b6df39ce8dfca942608e5b6a9a4f71:

  Merge remote-tracking branch 'remotes/kvaneesh/for-upstream' into staging 
(2014-03-08 12:38:43 +)

are available in the git repository at:


  git://github.com/rth7680/qemu.git tcg-aarch-6-1

for you to fetch changes up to f8e2484389acc564521d36cb7ca459428c134e7b:

  tcg-aarch64: Remove nop from qemu_st slow path (2014-03-08 21:23:25 -0800)


Richard Henderson (10):
  tcg-aarch64: Enable builtin disassembler
  tcg-aarch64: Remove redundant CPU_TLB_ENTRY_BITS check
  tcg-aarch64: Change all ext variables to TCGType
  tcg-aarch64: Set ext based on TCG_OPF_64BIT
  tcg-aarch64: Don't handle mov/movi in tcg_out_op
  tcg-aarch64: Hoist common argument loads in tcg_out_op
  tcg-aarch64: Remove the shift_imm parameter from tcg_out_cmp
  tcg-aarch64: Use intptr_t apropriately
  tcg-aarch64: Simplify tcg_out_ldst_9 encoding
  tcg-aarch64: Remove nop from qemu_st slow path

 configure|   6 +
 tcg/aarch64/tcg-target.c | 284 +--
 2 files changed, 130 insertions(+), 160 deletions(-)



[Qemu-devel] [PULL 03/10] tcg-aarch64: Change all ext variables to TCGType

2014-03-08 Thread Richard Henderson
We assert that the values for _I32 and _I64 are 0 and 1 respectively.
This will make a couple of functions declared by tcg.c cleaner.

Reviewed-by: Claudio Fontana claudio.font...@huawei.com
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/aarch64/tcg-target.c | 64 
 1 file changed, 37 insertions(+), 27 deletions(-)

diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c
index efbeac7..857f588 100644
--- a/tcg/aarch64/tcg-target.c
+++ b/tcg/aarch64/tcg-target.c
@@ -13,6 +13,11 @@
 #include tcg-be-ldst.h
 #include qemu/bitops.h
 
+/* We're going to re-use TCGType in setting of the SF bit, which controls
+   the size of the operation performed.  If we know the values match, it
+   makes things much cleaner.  */
+QEMU_BUILD_BUG_ON(TCG_TYPE_I32 != 0 || TCG_TYPE_I64 != 1);
+
 #ifndef NDEBUG
 static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
 %x0, %x1, %x2, %x3, %x4, %x5, %x6, %x7,
@@ -327,7 +332,8 @@ static inline void tcg_out_ldst_12(TCGContext *s,
   | op_type  20 | scaled_uimm  10 | rn  5 | rd);
 }
 
-static inline void tcg_out_movr(TCGContext *s, int ext, TCGReg rd, TCGReg src)
+static inline void tcg_out_movr(TCGContext *s, TCGType ext,
+TCGReg rd, TCGReg src)
 {
 /* register to register move using MOV (shifted register with no shift) */
 /* using MOV 0x2a0003e0 | (shift).. */
@@ -408,7 +414,8 @@ static inline void tcg_out_ldst(TCGContext *s, enum 
aarch64_ldst_op_data data,
 }
 
 /* mov alias implemented with add immediate, useful to move to/from SP */
-static inline void tcg_out_movr_sp(TCGContext *s, int ext, TCGReg rd, TCGReg 
rn)
+static inline void tcg_out_movr_sp(TCGContext *s, TCGType ext,
+   TCGReg rd, TCGReg rn)
 {
 /* using ADD 0x1100 | (ext) | rn  5 | rd */
 unsigned int base = ext ? 0x9100 : 0x1100;
@@ -438,7 +445,7 @@ static inline void tcg_out_st(TCGContext *s, TCGType type, 
TCGReg arg,
 }
 
 static inline void tcg_out_arith(TCGContext *s, enum aarch64_arith_opc opc,
- int ext, TCGReg rd, TCGReg rn, TCGReg rm,
+ TCGType ext, TCGReg rd, TCGReg rn, TCGReg rm,
  int shift_imm)
 {
 /* Using shifted register arithmetic operations */
@@ -454,7 +461,7 @@ static inline void tcg_out_arith(TCGContext *s, enum 
aarch64_arith_opc opc,
 tcg_out32(s, base | rm  16 | shift | rn  5 | rd);
 }
 
-static inline void tcg_out_mul(TCGContext *s, int ext,
+static inline void tcg_out_mul(TCGContext *s, TCGType ext,
TCGReg rd, TCGReg rn, TCGReg rm)
 {
 /* Using MADD 0x1b00 with Ra = wzr alias MUL 0x1b007c00 */
@@ -463,7 +470,7 @@ static inline void tcg_out_mul(TCGContext *s, int ext,
 }
 
 static inline void tcg_out_shiftrot_reg(TCGContext *s,
-enum aarch64_srr_opc opc, int ext,
+enum aarch64_srr_opc opc, TCGType ext,
 TCGReg rd, TCGReg rn, TCGReg rm)
 {
 /* using 2-source data processing instructions 0x1ac02000 */
@@ -471,23 +478,23 @@ static inline void tcg_out_shiftrot_reg(TCGContext *s,
 tcg_out32(s, base | rm  16 | opc  8 | rn  5 | rd);
 }
 
-static inline void tcg_out_ubfm(TCGContext *s, int ext, TCGReg rd, TCGReg rn,
-unsigned int a, unsigned int b)
+static inline void tcg_out_ubfm(TCGContext *s, TCGType ext, TCGReg rd,
+TCGReg rn, unsigned int a, unsigned int b)
 {
 /* Using UBFM 0x5300 Wd, Wn, a, b */
 unsigned int base = ext ? 0xd340 : 0x5300;
 tcg_out32(s, base | a  16 | b  10 | rn  5 | rd);
 }
 
-static inline void tcg_out_sbfm(TCGContext *s, int ext, TCGReg rd, TCGReg rn,
-unsigned int a, unsigned int b)
+static inline void tcg_out_sbfm(TCGContext *s, TCGType ext, TCGReg rd,
+TCGReg rn, unsigned int a, unsigned int b)
 {
 /* Using SBFM 0x1300 Wd, Wn, a, b */
 unsigned int base = ext ? 0x9340 : 0x1300;
 tcg_out32(s, base | a  16 | b  10 | rn  5 | rd);
 }
 
-static inline void tcg_out_extr(TCGContext *s, int ext, TCGReg rd,
+static inline void tcg_out_extr(TCGContext *s, TCGType ext, TCGReg rd,
 TCGReg rn, TCGReg rm, unsigned int a)
 {
 /* Using EXTR 0x1380 Wd, Wn, Wm, a */
@@ -495,7 +502,7 @@ static inline void tcg_out_extr(TCGContext *s, int ext, 
TCGReg rd,
 tcg_out32(s, base | rm  16 | a  10 | rn  5 | rd);
 }
 
-static inline void tcg_out_shl(TCGContext *s, int ext,
+static inline void tcg_out_shl(TCGContext *s, TCGType ext,
TCGReg rd, TCGReg rn, unsigned int m)
 {
 int bits, max;
@@ -504,28 +511,28 @@ static inline void tcg_out_shl(TCGContext *s, int ext,
 tcg_out_ubfm(s, ext, rd, 

[Qemu-devel] [PULL 02/10] tcg-aarch64: Remove redundant CPU_TLB_ENTRY_BITS check

2014-03-08 Thread Richard Henderson
Removed from other targets in 56bbc2f967ce185fa1c5c39e1aeb5b68b26242e9.

Reviewed-by: Alex Bennée alex.ben...@linaro.org
Reviewed-by: Claudio Fontana claudio.font...@huawei.com
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/aarch64/tcg-target.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c
index 04d7ae3..efbeac7 100644
--- a/tcg/aarch64/tcg-target.c
+++ b/tcg/aarch64/tcg-target.c
@@ -1441,12 +1441,6 @@ static const TCGTargetOpDef aarch64_op_defs[] = {
 
 static void tcg_target_init(TCGContext *s)
 {
-#if !defined(CONFIG_USER_ONLY)
-/* fail safe */
-if ((1ULL  CPU_TLB_ENTRY_BITS) != sizeof(CPUTLBEntry)) {
-tcg_abort();
-}
-#endif
 tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0x);
 tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0x);
 
-- 
1.8.5.3




[Qemu-devel] [PULL 10/10] tcg-aarch64: Remove nop from qemu_st slow path

2014-03-08 Thread Richard Henderson
Commit 023261ef851b22a04f6c5d76da870051031757a6 failed to remove a
nop that's no longer required.

Reviewed-by: Claudio Fontana claudio.font...@huawei.com
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/aarch64/tcg-target.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c
index d75d685..f43eb67 100644
--- a/tcg/aarch64/tcg-target.c
+++ b/tcg/aarch64/tcg-target.c
@@ -764,11 +764,6 @@ static inline void tcg_out_subi(TCGContext *s, TCGType ext,
 tcg_out32(s, base | aimm | (rn  5) | rd);
 }
 
-static inline void tcg_out_nop(TCGContext *s)
-{
-tcg_out32(s, 0xd503201f);
-}
-
 #ifdef CONFIG_SOFTMMU
 /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr,
  * int mmu_idx, uintptr_t ra)
@@ -822,8 +817,6 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, 
TCGLabelQemuLdst *lb)
 tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP,
  (intptr_t)qemu_st_helpers[lb-opc  3]);
 tcg_out_callr(s, TCG_REG_TMP);
-
-tcg_out_nop(s);
 tcg_out_goto(s, (tcg_target_long)lb-raddr);
 }
 
-- 
1.8.5.3




[Qemu-devel] [PULL 04/10] tcg-aarch64: Set ext based on TCG_OPF_64BIT

2014-03-08 Thread Richard Henderson
Reviewed-by: Alex Bennée alex.ben...@linaro.org
Reviewed-by: Claudio Fontana claudio.font...@huawei.com
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/aarch64/tcg-target.c | 28 +++-
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c
index 857f588..e3f55de 100644
--- a/tcg/aarch64/tcg-target.c
+++ b/tcg/aarch64/tcg-target.c
@@ -1100,9 +1100,9 @@ static inline void tcg_out_load_pair(TCGContext *s, 
TCGReg addr,
 static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args, const int *const_args)
 {
-/* ext will be set in the switch below, which will fall through to the
-   common code. It triggers the use of extended regs where appropriate. */
-TCGType ext = 0;
+/* 99% of the time, we can signal the use of extension registers
+   by looking to see if the opcode handles 64-bit data.  */
+TCGType ext = (tcg_op_defs[opc].flags  TCG_OPF_64BIT) != 0;
 
 switch (opc) {
 case INDEX_op_exit_tb:
@@ -1158,7 +1158,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 break;
 
 case INDEX_op_mov_i64:
-ext = 1; /* fall through */
 case INDEX_op_mov_i32:
 tcg_out_movr(s, ext, args[0], args[1]);
 break;
@@ -1171,43 +1170,36 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 break;
 
 case INDEX_op_add_i64:
-ext = 1; /* fall through */
 case INDEX_op_add_i32:
 tcg_out_arith(s, ARITH_ADD, ext, args[0], args[1], args[2], 0);
 break;
 
 case INDEX_op_sub_i64:
-ext = 1; /* fall through */
 case INDEX_op_sub_i32:
 tcg_out_arith(s, ARITH_SUB, ext, args[0], args[1], args[2], 0);
 break;
 
 case INDEX_op_and_i64:
-ext = 1; /* fall through */
 case INDEX_op_and_i32:
 tcg_out_arith(s, ARITH_AND, ext, args[0], args[1], args[2], 0);
 break;
 
 case INDEX_op_or_i64:
-ext = 1; /* fall through */
 case INDEX_op_or_i32:
 tcg_out_arith(s, ARITH_OR, ext, args[0], args[1], args[2], 0);
 break;
 
 case INDEX_op_xor_i64:
-ext = 1; /* fall through */
 case INDEX_op_xor_i32:
 tcg_out_arith(s, ARITH_XOR, ext, args[0], args[1], args[2], 0);
 break;
 
 case INDEX_op_mul_i64:
-ext = 1; /* fall through */
 case INDEX_op_mul_i32:
 tcg_out_mul(s, ext, args[0], args[1], args[2]);
 break;
 
 case INDEX_op_shl_i64:
-ext = 1; /* fall through */
 case INDEX_op_shl_i32:
 if (const_args[2]) {/* LSL / UBFM Wd, Wn, (32 - m) */
 tcg_out_shl(s, ext, args[0], args[1], args[2]);
@@ -1217,7 +1209,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 break;
 
 case INDEX_op_shr_i64:
-ext = 1; /* fall through */
 case INDEX_op_shr_i32:
 if (const_args[2]) {/* LSR / UBFM Wd, Wn, m, 31 */
 tcg_out_shr(s, ext, args[0], args[1], args[2]);
@@ -1227,7 +1218,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 break;
 
 case INDEX_op_sar_i64:
-ext = 1; /* fall through */
 case INDEX_op_sar_i32:
 if (const_args[2]) {/* ASR / SBFM Wd, Wn, m, 31 */
 tcg_out_sar(s, ext, args[0], args[1], args[2]);
@@ -1237,7 +1227,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 break;
 
 case INDEX_op_rotr_i64:
-ext = 1; /* fall through */
 case INDEX_op_rotr_i32:
 if (const_args[2]) {/* ROR / EXTR Wd, Wm, Wm, m */
 tcg_out_rotr(s, ext, args[0], args[1], args[2]);
@@ -1247,7 +1236,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 break;
 
 case INDEX_op_rotl_i64:
-ext = 1; /* fall through */
 case INDEX_op_rotl_i32: /* same as rotate right by (32 - m) */
 if (const_args[2]) {/* ROR / EXTR Wd, Wm, Wm, 32 - m */
 tcg_out_rotl(s, ext, args[0], args[1], args[2]);
@@ -1260,14 +1248,12 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 break;
 
 case INDEX_op_brcond_i64:
-ext = 1; /* fall through */
 case INDEX_op_brcond_i32: /* CMP 0, 1, cond(2), label 3 */
 tcg_out_cmp(s, ext, args[0], args[1], 0);
 tcg_out_goto_label_cond(s, args[2], args[3]);
 break;
 
 case INDEX_op_setcond_i64:
-ext = 1; /* fall through */
 case INDEX_op_setcond_i32:
 tcg_out_cmp(s, ext, args[1], args[2], 0);
 tcg_out_cset(s, 0, args[0], args[3]);
@@ -1310,9 +1296,11 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 tcg_out_qemu_st(s, args, 3);
 break;
 
-case INDEX_op_bswap64_i64:
-ext = 1; /* fall through */
 case INDEX_op_bswap32_i64:
+/* Despite the _i64, this is a 32-bit bswap.  */
+ext = 0;
+/* FALLTHRU */
+case INDEX_op_bswap64_i64:
 case INDEX_op_bswap32_i32:
 tcg_out_rev(s, ext, 

[Qemu-devel] [PULL 06/10] tcg-aarch64: Hoist common argument loads in tcg_out_op

2014-03-08 Thread Richard Henderson
This reduces the code size of the function significantly.

Reviewed-by: Alex Bennée alex.ben...@linaro.org
Reviewed-by: Claudio Fontana claudio.font...@huawei.com
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/aarch64/tcg-target.c | 95 +---
 1 file changed, 50 insertions(+), 45 deletions(-)

diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c
index 8f68450..dca7632 100644
--- a/tcg/aarch64/tcg-target.c
+++ b/tcg/aarch64/tcg-target.c
@@ -1098,15 +1098,22 @@ static inline void tcg_out_load_pair(TCGContext *s, 
TCGReg addr,
 }
 
 static void tcg_out_op(TCGContext *s, TCGOpcode opc,
-   const TCGArg *args, const int *const_args)
+   const TCGArg args[TCG_MAX_OP_ARGS],
+   const int const_args[TCG_MAX_OP_ARGS])
 {
 /* 99% of the time, we can signal the use of extension registers
by looking to see if the opcode handles 64-bit data.  */
 TCGType ext = (tcg_op_defs[opc].flags  TCG_OPF_64BIT) != 0;
 
+/* Hoist the loads of the most common arguments.  */
+TCGArg a0 = args[0];
+TCGArg a1 = args[1];
+TCGArg a2 = args[2];
+int c2 = const_args[2];
+
 switch (opc) {
 case INDEX_op_exit_tb:
-tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_X0, args[0]);
+tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_X0, a0);
 tcg_out_goto(s, (tcg_target_long)tb_ret_addr);
 break;
 
@@ -1115,23 +1122,23 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 #error USE_DIRECT_JUMP required for aarch64
 #endif
 assert(s-tb_jmp_offset != NULL); /* consistency for USE_DIRECT_JUMP */
-s-tb_jmp_offset[args[0]] = s-code_ptr - s-code_buf;
+s-tb_jmp_offset[a0] = s-code_ptr - s-code_buf;
 /* actual branch destination will be patched by
aarch64_tb_set_jmp_target later, beware retranslation. */
 tcg_out_goto_noaddr(s);
-s-tb_next_offset[args[0]] = s-code_ptr - s-code_buf;
+s-tb_next_offset[a0] = s-code_ptr - s-code_buf;
 break;
 
 case INDEX_op_call:
 if (const_args[0]) {
-tcg_out_call(s, args[0]);
+tcg_out_call(s, a0);
 } else {
-tcg_out_callr(s, args[0]);
+tcg_out_callr(s, a0);
 }
 break;
 
 case INDEX_op_br:
-tcg_out_goto_label(s, args[0]);
+tcg_out_goto_label(s, a0);
 break;
 
 case INDEX_op_ld_i32:
@@ -1154,97 +1161,95 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 case INDEX_op_st16_i64:
 case INDEX_op_st32_i64:
 tcg_out_ldst(s, aarch64_ldst_get_data(opc), aarch64_ldst_get_type(opc),
- args[0], args[1], args[2]);
+ a0, a1, a2);
 break;
 
 case INDEX_op_add_i64:
 case INDEX_op_add_i32:
-tcg_out_arith(s, ARITH_ADD, ext, args[0], args[1], args[2], 0);
+tcg_out_arith(s, ARITH_ADD, ext, a0, a1, a2, 0);
 break;
 
 case INDEX_op_sub_i64:
 case INDEX_op_sub_i32:
-tcg_out_arith(s, ARITH_SUB, ext, args[0], args[1], args[2], 0);
+tcg_out_arith(s, ARITH_SUB, ext, a0, a1, a2, 0);
 break;
 
 case INDEX_op_and_i64:
 case INDEX_op_and_i32:
-tcg_out_arith(s, ARITH_AND, ext, args[0], args[1], args[2], 0);
+tcg_out_arith(s, ARITH_AND, ext, a0, a1, a2, 0);
 break;
 
 case INDEX_op_or_i64:
 case INDEX_op_or_i32:
-tcg_out_arith(s, ARITH_OR, ext, args[0], args[1], args[2], 0);
+tcg_out_arith(s, ARITH_OR, ext, a0, a1, a2, 0);
 break;
 
 case INDEX_op_xor_i64:
 case INDEX_op_xor_i32:
-tcg_out_arith(s, ARITH_XOR, ext, args[0], args[1], args[2], 0);
+tcg_out_arith(s, ARITH_XOR, ext, a0, a1, a2, 0);
 break;
 
 case INDEX_op_mul_i64:
 case INDEX_op_mul_i32:
-tcg_out_mul(s, ext, args[0], args[1], args[2]);
+tcg_out_mul(s, ext, a0, a1, a2);
 break;
 
 case INDEX_op_shl_i64:
 case INDEX_op_shl_i32:
-if (const_args[2]) {/* LSL / UBFM Wd, Wn, (32 - m) */
-tcg_out_shl(s, ext, args[0], args[1], args[2]);
+if (c2) {/* LSL / UBFM Wd, Wn, (32 - m) */
+tcg_out_shl(s, ext, a0, a1, a2);
 } else {/* LSL / LSLV */
-tcg_out_shiftrot_reg(s, SRR_SHL, ext, args[0], args[1], args[2]);
+tcg_out_shiftrot_reg(s, SRR_SHL, ext, a0, a1, a2);
 }
 break;
 
 case INDEX_op_shr_i64:
 case INDEX_op_shr_i32:
-if (const_args[2]) {/* LSR / UBFM Wd, Wn, m, 31 */
-tcg_out_shr(s, ext, args[0], args[1], args[2]);
+if (c2) {/* LSR / UBFM Wd, Wn, m, 31 */
+tcg_out_shr(s, ext, a0, a1, a2);
 } else {/* LSR / LSRV */
-tcg_out_shiftrot_reg(s, SRR_SHR, ext, args[0], args[1], args[2]);
+tcg_out_shiftrot_reg(s, SRR_SHR, ext, a0, a1, a2);
 }
 break;
 
 

[Qemu-devel] [PULL 05/10] tcg-aarch64: Don't handle mov/movi in tcg_out_op

2014-03-08 Thread Richard Henderson
Reviewed-by: Claudio Fontana claudio.font...@huawei.com
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/aarch64/tcg-target.c | 20 +++-
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c
index e3f55de..8f68450 100644
--- a/tcg/aarch64/tcg-target.c
+++ b/tcg/aarch64/tcg-target.c
@@ -1157,18 +1157,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
  args[0], args[1], args[2]);
 break;
 
-case INDEX_op_mov_i64:
-case INDEX_op_mov_i32:
-tcg_out_movr(s, ext, args[0], args[1]);
-break;
-
-case INDEX_op_movi_i64:
-tcg_out_movi(s, TCG_TYPE_I64, args[0], args[1]);
-break;
-case INDEX_op_movi_i32:
-tcg_out_movi(s, TCG_TYPE_I32, args[0], args[1]);
-break;
-
 case INDEX_op_add_i64:
 case INDEX_op_add_i32:
 tcg_out_arith(s, ARITH_ADD, ext, args[0], args[1], args[2], 0);
@@ -1332,8 +1320,14 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 tcg_out_movr(s, 0, args[0], args[1]);
 break;
 
+case INDEX_op_mov_i64:
+case INDEX_op_mov_i32:
+case INDEX_op_movi_i64:
+case INDEX_op_movi_i32:
+/* Always implemented with tcg_out_mov/i, never with tcg_out_op.  */
 default:
-tcg_abort(); /* opcode not implemented */
+/* Opcode not implemented.  */
+tcg_abort();
 }
 }
 
-- 
1.8.5.3




[Qemu-devel] [PULL 07/10] tcg-aarch64: Remove the shift_imm parameter from tcg_out_cmp

2014-03-08 Thread Richard Henderson
It was unused.  Let's not overcomplicate things before we need them.

Reviewed-by: Claudio Fontana claudio.font...@huawei.com
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/aarch64/tcg-target.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c
index dca7632..2b55393 100644
--- a/tcg/aarch64/tcg-target.c
+++ b/tcg/aarch64/tcg-target.c
@@ -541,11 +541,10 @@ static inline void tcg_out_rotl(TCGContext *s, TCGType 
ext,
 tcg_out_extr(s, ext, rd, rn, rn, bits - (m  max));
 }
 
-static inline void tcg_out_cmp(TCGContext *s, TCGType ext, TCGReg rn,
-   TCGReg rm, int shift_imm)
+static void tcg_out_cmp(TCGContext *s, TCGType ext, TCGReg rn, TCGReg rm)
 {
 /* Using CMP alias SUBS wzr, Wn, Wm */
-tcg_out_arith(s, ARITH_SUBS, ext, TCG_REG_XZR, rn, rm, shift_imm);
+tcg_out_arith(s, ARITH_SUBS, ext, TCG_REG_XZR, rn, rm, 0);
 }
 
 static inline void tcg_out_cset(TCGContext *s, TCGType ext,
@@ -903,7 +902,7 @@ static void tcg_out_tlb_read(TCGContext *s, TCGReg addr_reg,
  (is_read ? offsetof(CPUTLBEntry, addr_read)
   : offsetof(CPUTLBEntry, addr_write)));
 /* Perform the address comparison. */
-tcg_out_cmp(s, (TARGET_LONG_BITS == 64), TCG_REG_X0, TCG_REG_X3, 0);
+tcg_out_cmp(s, (TARGET_LONG_BITS == 64), TCG_REG_X0, TCG_REG_X3);
 *label_ptr = s-code_ptr;
 /* If not equal, we jump to the slow path. */
 tcg_out_goto_cond_noaddr(s, TCG_COND_NE);
@@ -1242,13 +1241,13 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
 
 case INDEX_op_brcond_i64:
 case INDEX_op_brcond_i32:
-tcg_out_cmp(s, ext, a0, a1, 0);
+tcg_out_cmp(s, ext, a0, a1);
 tcg_out_goto_label_cond(s, a2, args[3]);
 break;
 
 case INDEX_op_setcond_i64:
 case INDEX_op_setcond_i32:
-tcg_out_cmp(s, ext, a1, a2, 0);
+tcg_out_cmp(s, ext, a1, a2);
 tcg_out_cset(s, 0, a0, args[3]);
 break;
 
-- 
1.8.5.3




[Qemu-devel] [PULL 08/10] tcg-aarch64: Use intptr_t apropriately

2014-03-08 Thread Richard Henderson
As opposed to tcg_target_long.

Reviewed-by: Claudio Fontana claudio.font...@huawei.com
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/aarch64/tcg-target.c | 49 +---
 1 file changed, 21 insertions(+), 28 deletions(-)

diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c
index 2b55393..58a5ff3 100644
--- a/tcg/aarch64/tcg-target.c
+++ b/tcg/aarch64/tcg-target.c
@@ -71,24 +71,22 @@ static const int tcg_target_call_oarg_regs[1] = {
 # endif
 #endif
 
-static inline void reloc_pc26(void *code_ptr, tcg_target_long target)
+static inline void reloc_pc26(void *code_ptr, intptr_t target)
 {
-tcg_target_long offset; uint32_t insn;
-offset = (target - (tcg_target_long)code_ptr) / 4;
+intptr_t offset = (target - (intptr_t)code_ptr) / 4;
 /* read instruction, mask away previous PC_REL26 parameter contents,
set the proper offset, then write back the instruction. */
-insn = *(uint32_t *)code_ptr;
+uint32_t insn = *(uint32_t *)code_ptr;
 insn = deposit32(insn, 0, 26, offset);
 *(uint32_t *)code_ptr = insn;
 }
 
-static inline void reloc_pc19(void *code_ptr, tcg_target_long target)
+static inline void reloc_pc19(void *code_ptr, intptr_t target)
 {
-tcg_target_long offset; uint32_t insn;
-offset = (target - (tcg_target_long)code_ptr) / 4;
+intptr_t offset = (target - (intptr_t)code_ptr) / 4;
 /* read instruction, mask away previous PC_REL19 parameter contents,
set the proper offset, then write back the instruction. */
-insn = *(uint32_t *)code_ptr;
+uint32_t insn = *(uint32_t *)code_ptr;
 insn = deposit32(insn, 5, 19, offset);
 *(uint32_t *)code_ptr = insn;
 }
@@ -555,10 +553,9 @@ static inline void tcg_out_cset(TCGContext *s, TCGType ext,
 tcg_out32(s, base | tcg_cond_to_aarch64[tcg_invert_cond(c)]  12 | rd);
 }
 
-static inline void tcg_out_goto(TCGContext *s, tcg_target_long target)
+static inline void tcg_out_goto(TCGContext *s, intptr_t target)
 {
-tcg_target_long offset;
-offset = (target - (tcg_target_long)s-code_ptr) / 4;
+intptr_t offset = (target - (intptr_t)s-code_ptr) / 4;
 
 if (offset  -0x0200 || offset = 0x0200) {
 /* out of 26bit range */
@@ -589,11 +586,9 @@ static inline void tcg_out_goto_cond_noaddr(TCGContext *s, 
TCGCond c)
 tcg_out32(s, insn);
 }
 
-static inline void tcg_out_goto_cond(TCGContext *s, TCGCond c,
- tcg_target_long target)
+static inline void tcg_out_goto_cond(TCGContext *s, TCGCond c, intptr_t target)
 {
-tcg_target_long offset;
-offset = (target - (tcg_target_long)s-code_ptr) / 4;
+intptr_t offset = (target - (intptr_t)s-code_ptr) / 4;
 
 if (offset  -0x4 || offset = 0x4) {
 /* out of 19bit range */
@@ -614,11 +609,9 @@ static inline void tcg_out_gotor(TCGContext *s, TCGReg reg)
 tcg_out32(s, 0xd61f | reg  5);
 }
 
-static inline void tcg_out_call(TCGContext *s, tcg_target_long target)
+static inline void tcg_out_call(TCGContext *s, intptr_t target)
 {
-tcg_target_long offset;
-
-offset = (target - (tcg_target_long)s-code_ptr) / 4;
+intptr_t offset = (target - (intptr_t)s-code_ptr) / 4;
 
 if (offset  -0x0200 || offset = 0x0200) { /* out of 26bit rng */
 tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, target);
@@ -670,9 +663,8 @@ static inline void tcg_out_ret(TCGContext *s)
 
 void aarch64_tb_set_jmp_target(uintptr_t jmp_addr, uintptr_t addr)
 {
-tcg_target_long target, offset;
-target = (tcg_target_long)addr;
-offset = (target - (tcg_target_long)jmp_addr) / 4;
+intptr_t target = addr;
+intptr_t offset = (target - (intptr_t)jmp_addr) / 4;
 
 if (offset  -0x0200 || offset = 0x0200) {
 /* out of 26bit range */
@@ -810,7 +802,8 @@ static const void * const qemu_st_helpers[4] = {
 
 static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)
 {
-reloc_pc19(lb-label_ptr[0], (tcg_target_long)s-code_ptr);
+reloc_pc19(lb-label_ptr[0], (intptr_t)s-code_ptr);
+
 tcg_out_movr(s, 1, TCG_REG_X0, TCG_AREG0);
 tcg_out_movr(s, (TARGET_LONG_BITS == 64), TCG_REG_X1, lb-addrlo_reg);
 tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X2, lb-mem_index);
@@ -824,20 +817,20 @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, 
TCGLabelQemuLdst *lb)
 tcg_out_movr(s, 1, lb-datalo_reg, TCG_REG_X0);
 }
 
-tcg_out_goto(s, (tcg_target_long)lb-raddr);
+tcg_out_goto(s, (intptr_t)lb-raddr);
 }
 
 static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)
 {
-reloc_pc19(lb-label_ptr[0], (tcg_target_long)s-code_ptr);
+reloc_pc19(lb-label_ptr[0], (intptr_t)s-code_ptr);
 
 tcg_out_movr(s, 1, TCG_REG_X0, TCG_AREG0);
 tcg_out_movr(s, (TARGET_LONG_BITS == 64), TCG_REG_X1, lb-addrlo_reg);
 tcg_out_movr(s, 1, TCG_REG_X2, lb-datalo_reg);
 tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X3, lb-mem_index);
-tcg_out_movi(s, 

[Qemu-devel] [PULL 09/10] tcg-aarch64: Simplify tcg_out_ldst_9 encoding

2014-03-08 Thread Richard Henderson
At first glance the code appears to be using 1's compliment encoding,
a-la AArch32.  Except that the constant is off, creating a complicated
split field 2's compliment encoding.

Much clearer to just use a normal mask and shift.

Reviewed-by: Claudio Fontana claudio.font...@huawei.com
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/aarch64/tcg-target.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c
index 58a5ff3..d75d685 100644
--- a/tcg/aarch64/tcg-target.c
+++ b/tcg/aarch64/tcg-target.c
@@ -305,18 +305,8 @@ static inline void tcg_out_ldst_9(TCGContext *s,
   TCGReg rd, TCGReg rn, tcg_target_long offset)
 {
 /* use LDUR with BASE register with 9bit signed unscaled offset */
-unsigned int mod, off;
-
-if (offset  0) {
-off = (256 + offset);
-mod = 0x1;
-} else {
-off = offset;
-mod = 0x0;
-}
-
-mod |= op_type;
-tcg_out32(s, op_data  24 | mod  20 | off  12 | rn  5 | rd);
+tcg_out32(s, op_data  24 | op_type  20
+  | (offset  0x1ff)  12 | rn  5 | rd);
 }
 
 /* tcg_out_ldst_12 expects a scaled unsigned immediate offset */
-- 
1.8.5.3




[Qemu-devel] [PULL 01/10] tcg-aarch64: Enable builtin disassembler

2014-03-08 Thread Richard Henderson
Reviewed-by: Alex Bennée alex.ben...@linaro.org
Reviewed-by: Claudio Fontana claudio.font...@huawei.com
Signed-off-by: Richard Henderson r...@twiddle.net
---
 configure | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/configure b/configure
index 8689435..af44b6a 100755
--- a/configure
+++ b/configure
@@ -4968,6 +4968,12 @@ for i in $ARCH $TARGET_BASE_ARCH ; do
 echo CONFIG_ALPHA_DIS=y   $config_target_mak
 echo CONFIG_ALPHA_DIS=y   config-all-disas.mak
   ;;
+  aarch64)
+if test -n ${cxx}; then
+  echo CONFIG_ARM_A64_DIS=y   $config_target_mak
+  echo CONFIG_ARM_A64_DIS=y   config-all-disas.mak
+fi
+  ;;
   arm)
 echo CONFIG_ARM_DIS=y   $config_target_mak
 echo CONFIG_ARM_DIS=y   config-all-disas.mak
-- 
1.8.5.3




Re: [Qemu-devel] [PATCH RFC 2/2] qemu-img: migrate to use qemu-arg

2014-03-08 Thread Paolo Bonzini

Il 08/03/2014 19:47, Leandro Dorileo ha scritto:

Remove the arg parsing implementations using getopt and use qemu-arg.
Also remove the qemu-img-cmds.hx since it's now generated on building time,
adapted the build system to generate the .hx file using the qemu-img itself
using the qemu-arg internal command generate-hx.

Signed-off-by: Leandro Dorileo l...@dorileo.org


This makes it much harder to cross-compile QEMU.  Also, I wonder how 
hard it would be to apply the same approach to the main QEMU binary 
which already uses QemuOpts for its more complex arguments; for sure you 
risk that accumulating multiple layers of abstractions makes the code 
even harder to read than it is now.


Paolo