[Qemu-devel] [Bug 1191326] Re: QNX 4 doesn't boot on qemu = 1.3

2013-08-24 Thread JQu
with qemu 1.6 is even worse - qemu crash every time when QNX detects
hard disk

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

Title:
  QNX 4 doesn't boot on qemu = 1.3

Status in QEMU:
  New

Bug description:
  
  I am using virtual machine with QNX4 operating system installed on it.  I 
updated my qemu from version
  to newer and QNX4 doesn't start any more. All is ok on version 1.2 but when I 
try to use any newer version 
  (1.3, 1.4, 1.5)  QNX4 doesn't boot.  I tried on windows and linux ubuntu 
hosts - effects are the same.

  When virtual machine boots qnx bootloader loads and starts operating system. 
In the next step
  qnx starts its ide driver, which detects qemu harddisk and cdrom. Problem 
starts when operating system
  tries mount partition - an error occur and qnx stop booting procedure:

  mount -p No bios signature in partition sector on /dev/hd0

  I have tried install qnx from cdrom but it seems that there is the same 
problem. QNX installer boot from
  cdrom, detects hard disk and cdrom, but cdrom can't be mounted in the next 
step of installation procedure.

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



Re: [Qemu-devel] [PATCH 1/2] target-arm: Use sextract32() in branch decode

2013-08-24 Thread Peter Maydell
On 23 August 2013 19:09, Richard Henderson r...@twiddle.net wrote:
 On 08/23/2013 09:12 AM, Peter Maydell wrote:
 -offset = (((int32_t)insn  8)  8);
 -val += (offset  2) + 4;
 +offset = sextract32(insn  2, 0, 26);
 +val += offset + 4;

 I read this incorrectly at first, considering the shift of insn, and
 I wonder if it's really the best way to write this because of that.

 What about just changing the one line to sextract(insn, 0, 24)?

 The second line by itself ought not trigger a warning from clang,
 because the  2 never changes the sign bit.  If it still does,
 perhaps just multiply by 4 instead...

No, left shift of a negative value is undefined: If E1 has a signed type
and nonnegative value, and E1 × 2E2 is representable in the result
type, then that is the resulting value; otherwise, the behavior is
undefined.

Also the ARM ARM pseudocode defines this operation as first
append two zero bits and then sign extend so I prefer it if we
actually implement it that way round.

 It's a stupid warning.  When was the last ones-compliment machine built?

The stupidity is that the C standard hasn't mandated 2s-complement.

-- PMM



Re: [Qemu-devel] [PATCH 1/4] kvm: Update headers for device control api

2013-08-24 Thread Peter Maydell
On 23 August 2013 20:40, Christoffer Dall christoffer.d...@linaro.org wrote:
 Update the KVM kernel headers to add support for the device control API
 on ARM used to create in-kernel devices and set and get attributes on
 these.

 This is needed for VGIC save/restore with KVM ARM targets.

 Headers are included from:
 git://git.linaro.org/people/cdall/linux-kvm-arm.git vgic-migrate

NB: this makes this an RFC patchset because we can't apply
it until the kernel headers have been accepted upstream.

-- PMM



Re: [Qemu-devel] [PATCH] kvm: sync cpu state on internal error before dump

2013-08-24 Thread Gleb Natapov
On Fri, Aug 23, 2013 at 02:41:13PM +0100, James Hogan wrote:
 On 23/08/13 13:58, Gleb Natapov wrote:
  On Fri, Aug 23, 2013 at 01:26:00PM +0100, James Hogan wrote:
  When a KVM internal error occurs QEMU dumps the CPU state, however it
  doesn't synchronise the state from KVM first so the dumped state is out
  of date. Add the synchronisation calls before the dump in both locations
  (which is used depends on whether the arch says to stop or not).
 
  x86_cpu_dump_state() calls cpu_synchronize_state() already.
 
 Ah yes, thanks. I hadn't noticed that.
 
 Out of the arches that support KVM only x86 and ppc call it. arm, mips
 (qemu support not upstream yet), and s390 don't. s390 never seems to
 emit that exit code, and arm only does so for unsupported exceptions
 (which should never happen).
 
 I'll fix in mips_cpu_dump_state() instead.
 
Moving cpu_synchronize_state() up to cpu_dump_state() would be better.

--
Gleb.



Re: [Qemu-devel] [PATCH 2/2] target-arm: Avoid 1 31 undefined behaviour

2013-08-24 Thread Peter Maydell
On 23 August 2013 19:11, Richard Henderson r...@twiddle.net wrote:
 On 08/23/2013 09:12 AM, Peter Maydell wrote:
  #define CPSR_V (1  28)
  #define CPSR_C (1  29)
  #define CPSR_Z (1  30)
 -#define CPSR_N (1  31)
 +#define CPSR_N (1U  31)
  #define CPSR_NZCV (CPSR_N | CPSR_Z | CPSR_C | CPSR_V)

 You'd be better off making all of the CPSR bits unsigned, I think.

Agreed; let's be consistent.

-- PMM



Re: [Qemu-devel] [qemu-devel] [PATCH v2] target-i386: Fix segment cache dump

2013-08-24 Thread Peter Maydell
On 23 August 2013 20:09, Tobias Markus tob...@markus-regensburg.de wrote:
 When in Long Mode, cpu_x86_seg_cache() logs DS16 because the Default 
 operation size bit (D/B bit) is not set for Long Mode Data Segments since 
 there are only Data Segments in Long Mode and no explicit 16/32/64-bit 
 Descriptors.
 This patch fixes this by checking the Long Mode Active bit of the hidden 
 flags variable and logging DS if it is set. (I.e. in Long Mode all Data 
 Segments are logged as DS)

If you need to do another version of this patch, it would be nice
to (manually) wrap the commit message and your below-the
comments at about column 75. Otherwise whoever commits
the patch could maybe fix up the message.

thanks
-- PMM



Re: [Qemu-devel] [PATCH] sun4m: Add FCode ROM for TCX framebuffer

2013-08-24 Thread Mark Cave-Ayland

On 21/08/13 18:06, Peter Maydell wrote:


Okay so in that case what is the best way to manage to process? If both this
and the follow-up patchset are committed first without the associated FCode
ROM images then qemu-system-sparc will be broken until the main OpenBIOS
images are updated because (quite rightly) the TCX driver will attempt to
load the ROM at startup and fail because they aren't present...?

Is the best way to send a pull request for the update OpenBIOS images plus
associated FCode ROMs first and then work on getting the QEMU patches
applied? This isn't strictly correct, but the display code currently has a
panic fallback in place where it should try and load an inbuilt TCX driver
if it doesn't find a valid display ROM during probe.


I guess Anthony gets to make the call on what we should do here,
but my opinion is that if the problem is effectively these QEMU
changes must be in sync with these updated OpenBIOS images then
(a) something's wrong because having QEMU that closely coupled
to firmware is rather dubious and (b) there should be a single patch
[and thus a single git commit] which both updates QEMU and updates
the blobs in our repo and updates the gitmodule to point at the
sources we used to build those blobs].


Just to clarify that all of the changes don't have to go in one commit, 
since the current OpenBIOS has a (temporary) fallback to use an internal 
copy of the old hard-wired TCX FCode blob if it can't locate a suitable 
display ROM. While this may be removed longer term, I think it's a 
reasonable compromise in order to maintain bisectability of the QEMU 
tree at the moment.


Based upon this thread, my preferred method would be this:

1) Get Anthony to update the OpenBIOS git repository on git.qemu.org

2) Update the existing OpenBIOS images for all architectures on my
   github account and send a pull request

3) Rework the patch based upon yours/Andreas' suggestions and resubmit
   to the qemu-devel list, including the new TCX FCode ROM

4) Get TCX driver patch applied

Any future updates to OpenBIOS will also update the TCX ROM image, 
although I'm fairly sure that changes in the ROM aren't likely to occur 
often if at all. Does that sound reasonable to everyone?



ATB,

Mark.



[Qemu-devel] Disable scaling of SDL

2013-08-24 Thread Taimoor Mirza
Hi guys,

I am using QEMU with SDL support to run some demo applications.
Problem I am facing is that fonts in my SDL window are not displayed
properly. I have to press Ctrl+Alt+u to undo scaling. After that fonts
display correctly.
Is there any way I can disable scaling in SDL window?

Thanks,
Taimoor



[Qemu-devel] Changes to QEMU's timer system

2013-08-24 Thread Alex Bligh

I did a blog post on the aio-timers changes I made to the timer system,
including a diagram of how it works now:
 http://blog.alex.org.uk/2013/08/24/changes-to-qemus-timer-system/

Comments welcome.

--
Alex Bligh



Re: [Qemu-devel] [PATCH] kvm: sync cpu state on internal error before dump

2013-08-24 Thread Andreas Färber
Am 24.08.2013 12:37, schrieb Gleb Natapov:
 On Fri, Aug 23, 2013 at 02:41:13PM +0100, James Hogan wrote:
 On 23/08/13 13:58, Gleb Natapov wrote:
 On Fri, Aug 23, 2013 at 01:26:00PM +0100, James Hogan wrote:
 When a KVM internal error occurs QEMU dumps the CPU state, however it
 doesn't synchronise the state from KVM first so the dumped state is out
 of date. Add the synchronisation calls before the dump in both locations
 (which is used depends on whether the arch says to stop or not).

 x86_cpu_dump_state() calls cpu_synchronize_state() already.

 Ah yes, thanks. I hadn't noticed that.

 Out of the arches that support KVM only x86 and ppc call it. arm, mips
 (qemu support not upstream yet), and s390 don't. s390 never seems to
 emit that exit code, and arm only does so for unsupported exceptions
 (which should never happen).

 I'll fix in mips_cpu_dump_state() instead.

 Moving cpu_synchronize_state() up to cpu_dump_state() would be better.

Yes, please. I did not review the hooks themselves much, just avoided
global functions.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [Bug 1191326] Re: QNX 4 doesn't boot on qemu = 1.3

2013-08-24 Thread Andreas Färber
Please use git-bisect to find out which change between 1.2.0 and 1.3.0
broke things for you.

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

Title:
  QNX 4 doesn't boot on qemu = 1.3

Status in QEMU:
  New

Bug description:
  
  I am using virtual machine with QNX4 operating system installed on it.  I 
updated my qemu from version
  to newer and QNX4 doesn't start any more. All is ok on version 1.2 but when I 
try to use any newer version 
  (1.3, 1.4, 1.5)  QNX4 doesn't boot.  I tried on windows and linux ubuntu 
hosts - effects are the same.

  When virtual machine boots qnx bootloader loads and starts operating system. 
In the next step
  qnx starts its ide driver, which detects qemu harddisk and cdrom. Problem 
starts when operating system
  tries mount partition - an error occur and qnx stop booting procedure:

  mount -p No bios signature in partition sector on /dev/hd0

  I have tried install qnx from cdrom but it seems that there is the same 
problem. QNX installer boot from
  cdrom, detects hard disk and cdrom, but cdrom can't be mounted in the next 
step of installation procedure.

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



[Qemu-devel] [Bug 1216368] [NEW] unsupported screen resolution crashes sdl-qemu

2013-08-24 Thread Sascha Krissler
Public bug reported:

if the (windows) guest sets a screen resolution that the SDL backend does not 
support,
qemu does an exit(1).
with this fix, the the resolution is still wrong (only part of the desktop is 
displayed),
but qemu keeps running and the guest can auto-revert the video mode:

ui/sdl.c:do_sdl_resize()
SDL_Surface * tmp_screen;
tmp_screen = SDL_SetVideoMode(width, height, bpp, flags);
if (!tmp_screen) {
//  fprintf(stderr, Could not open SDL display (%dx%dx%d): %s\n, width, 
//  height, bpp, SDL_GetError());
//  exit(1);
} else {
real_screen = tmp_screen;
}

** Affects: qemu
 Importance: Undecided
 Status: New

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

Title:
  unsupported screen resolution crashes sdl-qemu

Status in QEMU:
  New

Bug description:
  if the (windows) guest sets a screen resolution that the SDL backend does not 
support,
  qemu does an exit(1).
  with this fix, the the resolution is still wrong (only part of the desktop is 
displayed),
  but qemu keeps running and the guest can auto-revert the video mode:

  ui/sdl.c:do_sdl_resize()
  SDL_Surface * tmp_screen;
  tmp_screen = SDL_SetVideoMode(width, height, bpp, flags);
  if (!tmp_screen) {
  //  fprintf(stderr, Could not open SDL display (%dx%dx%d): %s\n, width, 
  //  height, bpp, SDL_GetError());
  //  exit(1);
  } else {
  real_screen = tmp_screen;
  }

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



Re: [Qemu-devel] [PATCH] sun4m: Add FCode ROM for TCX framebuffer

2013-08-24 Thread Andreas Färber
Am 21.08.2013 20:52, schrieb Mark Cave-Ayland:
 On 21/08/13 18:54, Andreas Färber wrote:
 
 Shouldn't this blob come in the same patch as an update to some
 git module, so that we keep track of the sources used to build
 the blob?

 I concur. Independent of how to order the .gitmodules update, this patch
 is missing Makefile support to actually copy the new binary from
 OpenBIOS build to the location it is being added to as binary here.
 
 Okay that's something else to add to the v2 :)

On second thoughts, more important than Makefile changes (which would
depend on the OpenBIOS gitmodule update) would be to document textually
in the README wherever the openbios-sparc origin is tracked that this
file comes from OpenBIOS r, too.

 --- a/hw/sparc/sun4m.c
 +++ b/hw/sparc/sun4m.c

 +fcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
 TCX_ROM_FILE);
 +if (fcode_filename) {
 +ret = load_image_targphys(fcode_filename, addr,
 FCODE_MAX_ROM_SIZE);
 +}

 This looks like the wrong place for this -- surely the tcx device
 should load its own fcode blob, not defer to the board code
 to do it?

 (For that matter, presumably if this is an SBus device then
 the offsets of the ROM, DAC, etc etc are all fixed relative to
 the base address of the SBus slot, and the tcx device itself
 should be creating a container with all its component parts
 at the right offset. But that's not an issue for this patch.)

 I vaguely recall Mark telling me that SBus is not really
 qdev'ified/QOM'ified, right?

 PCI devices have support for ROM files, too, and I think they just set
 the file name and generic PCI code takes care of the actual loading.
 Maybe we would want to do the same for SBus? We're not in a rush yet so
 getting this designed right probably only takes a week or so...
 
 Currently there is no concept of an SBus in QEMU, since the bus address
 lines are effectively mapped to the processor bus (and so the standard
 sysbus calls work just fine). I know this isn't the complete truth with
 respect to real hardware, though I suspect Blue/Bob could expand further
 on this if required.

Seems I mixed that up with CBus then. ;)

So, TCX is a SysBusDevice. How do I recognize which devices are SBus
devices? Do you have a list of files/types or some recipe to find out?

With QOM it would be easily possible to derive a TYPE_SBUS_DEVICE from
TYPE_SYS_BUS_DEVICE and have TYPE_TCX be derived from it. Then
SBusDeviceClass could supply a rom_file field, which generic SBus code
loads in its realizefn while still being able to use sysbus_*() API.

Cheers,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [Bug 1198350] Re: USB pass-through fails with USBDEVFS_DISCONNECT: Invalid argument

2013-08-24 Thread Mike
I also have this issue. Does anyone have a work around? (it works with
Virtual Box)

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

Title:
  USB pass-through fails with USBDEVFS_DISCONNECT: Invalid argument

Status in QEMU:
  New

Bug description:
  Host Gentoo linux 32bit
  Guest Windows XP SP3
  qemu 1.4.2 and
  qemu fresh get clone and build 2013-07-04 (version1.5.50)
  qemu command line

  qemu-system-i386 -enable-kvm localtime -m 2047 -boot d
  /archive3/qemu/WindowsXP.img -net nic,model=rtl8139 -net user -usb
  -device usb-ehci,id=ehci -usbdevice host:1493:19

  The device I am trying to use with the guest is an interface for the
  Suunto Ambit 2 GPS watch which has no linux support.

  When the USB device is plugged in qemu reports to the command line:

  USBDEVFS_DISCONNECT: Invalid argument
  Invalid argument

  dmesg shows

  [237755.495968] usb 2-1.5: new full-speed USB device number 34 using ehci-pci
  [237755.582778] usb 2-1.5: config 1 has an invalid interface number: 1 but 
max is 0
  [237755.582781] usb 2-1.5: config 1 has no interface number 0
  [237755.583628] usb 2-1.5: New USB device found, idVendor=1493, idProduct=0019
  [237755.583631] usb 2-1.5: New USB device strings: Mfr=1, Product=2, 
SerialNumber=3
  [237755.583633] usb 2-1.5: Product: Ambit
  [237755.583634] usb 2-1.5: Manufacturer: Suunto
  [237755.583636] usb 2-1.5: SerialNumber: CE8309511700
  [237756.584937] usb 2-1.5: reset full-speed USB device number 34 using 
ehci-pci
  [237756.832658] usb 2-1.5: reset full-speed USB device number 34 using 
ehci-pci
  [237757.143585] usb 2-1.5: usbfs: process 12684 (qemu-system-i38) did not 
claim interface 1 before use

  In the windows guest Device Manager a HID device is listed but nothing
  else happens, no found new hardware dialog or the Suunto software
  (which is sitting there waiting) is not triggered as it should be.

  I have tried successfully with several other devices (flash drive,
  mouse, printer and video capture device). Because this device pretends
  to be an HID device my kernel's hid-generic driver was picking it up
  first until I modified hid-core.c to ignore this vendorid/productid.
  But still no joy.

  I'm guessing it has something to do with the the dmesg lines:

  [237755.582778] usb 2-1.5: config 1 has an invalid interface number: 1 but 
max is 0
  [237755.582781] usb 2-1.5: config 1 has no interface number 0

  But read that these warnings are not important though I don't get them
  for other devices. Nor do I get:

  [237757.143585] usb 2-1.5: usbfs: process 12684 (qemu-system-i38) did
  not claim interface 1 before use

  I've done alot of searching and I've run out of ideas. Any help would
  be great.

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



Re: [Qemu-devel] Disable scaling of SDL

2013-08-24 Thread Stefan Weil
Am 24.08.2013 15:43, schrieb Taimoor Mirza:
 Hi guys,

 I am using QEMU with SDL support to run some demo applications.
 Problem I am facing is that fonts in my SDL window are not displayed
 properly. I have to press Ctrl+Alt+u to undo scaling. After that fonts
 display correctly.
 Is there any way I can disable scaling in SDL window?

 Thanks,
 Taimoor

Hi Taimoor,

currently the only way to disable scaling is modifying the
source code and building your own binaries.

SDL scaling is indeed not useful, uses broken code for
all platforms and scales without reason on Windows host.

http://patchwork.ozlabs.org/patch/155925/ is a patch
which disables it.

Regards,
Stefan





[Qemu-devel] [RFC PATCH] Introduce RCU-enabled DQs (v2)

2013-08-24 Thread Mike Day
Add RCU-enabled variants on the existing bsd DQ facility. Each Q
operation has the same interface as the existing (non-RCU)
version. Also, each operation is implemented as macro for now.

Using the RCU-enabled DQ, existing DQ users will be able to convert to
RCU without using a different list interface.

This version (2) adds a macro to walk a Q in reverse:

QLIST_FOREACH_REVERSE_RCU(el, head, field)

Accordingly the reader threads in the test program walk the Q in
reverse in addition to walking forward.

To accompany the RCU-enabled DQ, there is also a test file that uses
concurrent readers to contend with a single updater.

This patchset builds on top of Paolo Bonzini's rcu tree:
https://github.com/bonzini/qemu/tree/rcu

Signed-off-by: Mike Day ncm...@ncultra.org
---
 docs/rcu.txt |   2 +-
 include/qemu/queue.h |  11 --
 include/qemu/rcu_queue.h | 145 
 tests/Makefile   |   6 +-
 tests/rcuq_test.c| 290 +++
 5 files changed, 440 insertions(+), 14 deletions(-)
 create mode 100644 include/qemu/rcu_queue.h
 create mode 100644 tests/rcuq_test.c

diff --git a/docs/rcu.txt b/docs/rcu.txt
index b3c593c..de59896 100644
--- a/docs/rcu.txt
+++ b/docs/rcu.txt
@@ -106,7 +106,7 @@ The core RCU API is small:
 so that the reclaimer function can fetch the struct foo address
 and free it:
 
-call_rcu1(foo_reclaim, foo.rcu);
+call_rcu1(foo.rcu, foo_reclaim);
 
 void foo_reclaim(struct rcu_head *rp)
 {
diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index 847ddd1..f6f0636 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -139,17 +139,6 @@ struct {   
 \
 (elm)-field.le_prev = (head)-lh_first;   \
 } while (/*CONSTCOND*/0)
 
-#define QLIST_INSERT_HEAD_RCU(head, elm, field) do {\
-(elm)-field.le_prev = (head)-lh_first;   \
-(elm)-field.le_next = (head)-lh_first;\
-smp_wmb(); /* fill elm before linking it */ \
-if ((head)-lh_first != NULL)  {\
-(head)-lh_first-field.le_prev = (elm)-field.le_next;\
-}   \
-(head)-lh_first = (elm);   \
-smp_wmb();  \
-} while (/* CONSTCOND*/0)
-
 #define QLIST_REMOVE(elm, field) do {   \
 if ((elm)-field.le_next != NULL)   \
 (elm)-field.le_next-field.le_prev =   \
diff --git a/include/qemu/rcu_queue.h b/include/qemu/rcu_queue.h
new file mode 100644
index 000..198a87d
--- /dev/null
+++ b/include/qemu/rcu_queue.h
@@ -0,0 +1,145 @@
+#ifndef QEMU_RCU_SYS_QUEUE_H
+#define QEMU_RCU_SYS_QUEUE_H
+
+/*
+ * rc_queue.h
+ *
+ * Userspace RCU QSBR header.
+ *
+ * LGPL-compatible code should include this header with :
+ *
+ * #define _LGPL_SOURCE
+ * #include urcu.h
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Copyright (c) 2013 Mike D. Day, IBM Corporation.
+ *
+ * IBM's contributions to this file may be relicensed under LGPLv2 or later.
+ */
+
+#include qemu/rcu.h  /* rcu.h includes qemu/queue.h and qemu/atomic.h */
+
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+/*
+ * List functions.
+ */
+
+
+/*
+ *  The difference between atomic_read/set and atomic_rcu_read/set
+ *  is in the including of a read/write memory barrier to the volatile
+ *  access. atomic_rcu_* macros include the memory barrier, the
+ *  plain atomic macros do not. Therefore, it should be correct to
+ *  issue a series of reads or writes to the same element using only
+ *  the atomic_* macro, until the last read or write, which should be
+ *  atomic_rcu_* to introduce a read or write memory barrier as
+ *  appropriate.
+ */
+
+/* Upon publication of the listelm-next value, list readers
+ * will see the new node when following next pointers from
+ * antecedent nodes, but may not see the new node when following
+ * prev pointers from 

[Qemu-devel] [PATCH] target-xtensa: add in_asm logging

2013-08-24 Thread Max Filippov
Signed-off-by: Max Filippov jcmvb...@gmail.com
---
 target-xtensa/translate.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c
index 504cc53..c82d988 100644
--- a/target-xtensa/translate.c
+++ b/target-xtensa/translate.c
@@ -3018,6 +3018,14 @@ void gen_intermediate_code_internal(XtensaCPU *cpu,
 gen_tb_end(tb, insn_count);
 *tcg_ctx.gen_opc_ptr = INDEX_op_end;
 
+#ifdef DEBUG_DISAS
+if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
+qemu_log(\n);
+qemu_log(IN: %s\n, lookup_symbol(pc_start));
+log_target_disas(env, pc_start, dc.pc - pc_start, 0);
+qemu_log(\n);
+}
+#endif
 if (search_pc) {
 j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
 memset(tcg_ctx.gen_opc_instr_start + lj + 1, 0,
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH v3 3/3] slirp: set mainloop timeout with more precise value

2013-08-24 Thread liu ping fan
On Sat, Aug 24, 2013 at 12:49 AM, Jan Kiszka jan.kis...@siemens.com wrote:
 On 2013-08-21 10:07, liu ping fan wrote:
 On Wed, Aug 21, 2013 at 3:36 PM, Alex Bligh a...@alex.org.uk wrote:


 --On 21 August 2013 10:15:52 +0800 Liu Ping Fan qemul...@gmail.com wrote:

 -void slirp_update_timeout(uint32_t *timeout)
 +static void slirp_update_timeout(uint32_t *timeout)
  {
 -if (!QTAILQ_EMPTY(slirp_instances)) {
 -*timeout = MIN(1000, *timeout);


 If you are putting things in macros, you might as well change that

 TIMEOUT_FAST/SLOW have definite meaning, and used more than one place
 in the code. For 1000ms, I do not know this magic value's meaning, but
 whatever, it just occurs once. So there is no trouble to read the
 code.

 You could name it ONE_SEC or so. Can be done as trivial patch on top.

 IIRC, slirp requires regular polling for the aging of certain requests
 like DNS.

Thanks for the explanation. Will fix and document it.

Regards,
Pingfan



Re: [Qemu-devel] [PATCH v3 3/3] slirp: set mainloop timeout with more precise value

2013-08-24 Thread liu ping fan
On Sat, Aug 24, 2013 at 12:54 AM, Jan Kiszka jan.kis...@siemens.com wrote:
 On 2013-08-21 04:15, Liu Ping Fan wrote:
 If slirp needs to emulate tcp timeout, then the timeout value
 for mainloop should be more precise, which is determined by
 slirp's fasttimo or slowtimo. Achieve this by swap the logic
 sequence of slirp_pollfds_fill and slirp_update_timeout.

 Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com
 ---
  main-loop.c  |  3 +--
  slirp/libslirp.h |  3 +--
  slirp/slirp.c| 28 
  stubs/slirp.c|  6 +-
  4 files changed, 27 insertions(+), 13 deletions(-)

 diff --git a/main-loop.c b/main-loop.c
 index a44fff6..e258567 100644
 --- a/main-loop.c
 +++ b/main-loop.c
 @@ -458,8 +458,7 @@ int main_loop_wait(int nonblocking)
  g_array_set_size(gpollfds, 0); /* reset for new iteration */
  /* XXX: separate device handlers from system ones */
  #ifdef CONFIG_SLIRP
 -slirp_update_timeout(timeout);
 -slirp_pollfds_fill(gpollfds);
 +slirp_pollfds_fill(gpollfds, timeout);
  #endif
  qemu_iohandler_fill(gpollfds);
  ret = os_host_main_loop_wait(timeout);
 diff --git a/slirp/libslirp.h b/slirp/libslirp.h
 index ceabff8..5bdcbd5 100644
 --- a/slirp/libslirp.h
 +++ b/slirp/libslirp.h
 @@ -16,8 +16,7 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork,
void *opaque);
  void slirp_cleanup(Slirp *slirp);

 -void slirp_update_timeout(uint32_t *timeout);
 -void slirp_pollfds_fill(GArray *pollfds);
 +void slirp_pollfds_fill(GArray *pollfds, uint32_t *timeout);

  void slirp_pollfds_poll(GArray *pollfds, int select_error);

 diff --git a/slirp/slirp.c b/slirp/slirp.c
 index 1e8983e..f312a7d 100644
 --- a/slirp/slirp.c
 +++ b/slirp/slirp.c
 @@ -260,14 +260,33 @@ void slirp_cleanup(Slirp *slirp)
  #define CONN_CANFSEND(so) (((so)-so_state  
 (SS_FCANTSENDMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)
  #define CONN_CANFRCV(so) (((so)-so_state  
 (SS_FCANTRCVMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)

 -void slirp_update_timeout(uint32_t *timeout)
 +static void slirp_update_timeout(uint32_t *timeout)
  {
 -if (!QTAILQ_EMPTY(slirp_instances)) {
 -*timeout = MIN(1000, *timeout);
 +Slirp *slirp;
 +uint32_t t;
 +
 +*timeout = MIN(1000, *timeout);
 +if (*timeout = TIMEOUT_FAST) {

 Nitpicking, sorry, but TIMEOUT_FAST is always smaller than 1000. So this
 check should come first, and then the MIN assignment (to t).

Will fix.

Regards,
Pingfan



[Qemu-devel] [PATCH v4 1/3] slirp: make timeout local

2013-08-24 Thread Liu Ping Fan
Each slirp has its own time to caculate timeout.

Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com
---
 slirp/slirp.c | 22 ++
 slirp/slirp.h |  3 +++
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/slirp/slirp.c b/slirp/slirp.c
index 80b28ea..b71c617 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -40,8 +40,6 @@ static const uint8_t special_ethaddr[ETH_ALEN] = {
 static const uint8_t zero_ethaddr[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
 
 u_int curtime;
-static u_int time_fasttimo, last_slowtimo;
-static int do_slowtimo;
 
 static QTAILQ_HEAD(slirp_instances, Slirp) slirp_instances =
 QTAILQ_HEAD_INITIALIZER(slirp_instances);
@@ -278,14 +276,13 @@ void slirp_pollfds_fill(GArray *pollfds)
 /*
  * First, TCP sockets
  */
-do_slowtimo = 0;
 
 QTAILQ_FOREACH(slirp, slirp_instances, entry) {
 /*
  * *_slowtimo needs calling if there are IP fragments
  * in the fragment queue, or there are TCP connections active
  */
-do_slowtimo |= ((slirp-tcb.so_next != slirp-tcb) ||
+slirp-do_slowtimo = ((slirp-tcb.so_next != slirp-tcb) ||
 (slirp-ipq.ip_link != slirp-ipq.ip_link.next));
 
 for (so = slirp-tcb.so_next; so != slirp-tcb;
@@ -299,8 +296,9 @@ void slirp_pollfds_fill(GArray *pollfds)
 /*
  * See if we need a tcp_fasttimo
  */
-if (time_fasttimo == 0  so-so_tcpcb-t_flags  TF_DELACK) {
-time_fasttimo = curtime; /* Flag when we want a fasttimo */
+if (slirp-time_fasttimo == 0 
+so-so_tcpcb-t_flags  TF_DELACK) {
+slirp-time_fasttimo = curtime; /* Flag when want a fasttimo */
 }
 
 /*
@@ -381,7 +379,7 @@ void slirp_pollfds_fill(GArray *pollfds)
 udp_detach(so);
 continue;
 } else {
-do_slowtimo = 1; /* Let socket expire */
+slirp-do_slowtimo = true; /* Let socket expire */
 }
 }
 
@@ -422,7 +420,7 @@ void slirp_pollfds_fill(GArray *pollfds)
 icmp_detach(so);
 continue;
 } else {
-do_slowtimo = 1; /* Let socket expire */
+slirp-do_slowtimo = true; /* Let socket expire */
 }
 }
 
@@ -454,14 +452,14 @@ void slirp_pollfds_poll(GArray *pollfds, int select_error)
 /*
  * See if anything has timed out
  */
-if (time_fasttimo  ((curtime - time_fasttimo) = 2)) {
+if (slirp-time_fasttimo  ((curtime - slirp-time_fasttimo) = 2)) {
 tcp_fasttimo(slirp);
-time_fasttimo = 0;
+slirp-time_fasttimo = 0;
 }
-if (do_slowtimo  ((curtime - last_slowtimo) = 499)) {
+if (slirp-do_slowtimo  ((curtime - slirp-last_slowtimo) = 499)) {
 ip_slowtimo(slirp);
 tcp_slowtimo(slirp);
-last_slowtimo = curtime;
+slirp-last_slowtimo = curtime;
 }
 
 /*
diff --git a/slirp/slirp.h b/slirp/slirp.h
index fe0e65d..e4a1bd4 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -203,6 +203,9 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr,
 
 struct Slirp {
 QTAILQ_ENTRY(Slirp) entry;
+u_int time_fasttimo;
+u_int last_slowtimo;
+bool do_slowtimo;
 
 /* virtual network configuration */
 struct in_addr vnetwork_addr;
-- 
1.8.1.4




[Qemu-devel] [PATCH v4 0/3] slirp: fill mainloop with more precise timeout value

2013-08-24 Thread Liu Ping Fan
With this series, we can set the mainloop timeout more precisely when slirp has
to emulate tcp timeout problem.

v4:
  use macro TIMEOUT_DEFAULT to define the default timeout of slirp and document 
it.

v3:
  fix comment: document timeout unit milliseconds
  fix logic: no slirps, no timeout modifications in slirp_pollfds_fill()
v2:
  fold slirp_update_timeout logic into slirp_pollfds_fill.


Liu Ping Fan (3):
  slirp: make timeout local
  slirp: define timeout as macro
  slirp: set mainloop timeout with more precise value

 main-loop.c  |  3 +--
 slirp/libslirp.h |  3 +--
 slirp/slirp.c| 61 +++-
 slirp/slirp.h|  3 +++
 stubs/slirp.c|  6 +-
 5 files changed, 49 insertions(+), 27 deletions(-)

-- 
1.8.1.4




[Qemu-devel] [PATCH v4 3/3] slirp: set mainloop timeout with more precise value

2013-08-24 Thread Liu Ping Fan
If slirp needs to emulate tcp timeout, then the timeout value
for mainloop should be more precise, which is determined by
slirp's fasttimo or slowtimo. Achieve this by swap the logic
sequence of slirp_pollfds_fill and slirp_update_timeout.

Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com
---
 main-loop.c  |  3 +--
 slirp/libslirp.h |  3 +--
 slirp/slirp.c| 28 
 stubs/slirp.c|  6 +-
 4 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/main-loop.c b/main-loop.c
index a44fff6..e258567 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -458,8 +458,7 @@ int main_loop_wait(int nonblocking)
 g_array_set_size(gpollfds, 0); /* reset for new iteration */
 /* XXX: separate device handlers from system ones */
 #ifdef CONFIG_SLIRP
-slirp_update_timeout(timeout);
-slirp_pollfds_fill(gpollfds);
+slirp_pollfds_fill(gpollfds, timeout);
 #endif
 qemu_iohandler_fill(gpollfds);
 ret = os_host_main_loop_wait(timeout);
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index ceabff8..5bdcbd5 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -16,8 +16,7 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork,
   void *opaque);
 void slirp_cleanup(Slirp *slirp);
 
-void slirp_update_timeout(uint32_t *timeout);
-void slirp_pollfds_fill(GArray *pollfds);
+void slirp_pollfds_fill(GArray *pollfds, uint32_t *timeout);
 
 void slirp_pollfds_poll(GArray *pollfds, int select_error);
 
diff --git a/slirp/slirp.c b/slirp/slirp.c
index c47af8f..63976dc 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -262,14 +262,33 @@ void slirp_cleanup(Slirp *slirp)
 #define CONN_CANFSEND(so) (((so)-so_state  
(SS_FCANTSENDMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)
 #define CONN_CANFRCV(so) (((so)-so_state  (SS_FCANTRCVMORE|SS_ISFCONNECTED)) 
== SS_ISFCONNECTED)
 
-void slirp_update_timeout(uint32_t *timeout)
+static void slirp_update_timeout(uint32_t *timeout)
 {
-if (!QTAILQ_EMPTY(slirp_instances)) {
-*timeout = MIN(TIMEOUT_DEFAULT, *timeout);
+Slirp *slirp;
+uint32_t t;
+
+if (*timeout = TIMEOUT_FAST) {
+return;
+}
+*timeout = MIN(1000, *timeout);
+t = *timeout;
+
+/* If we have tcp timeout with slirp, then we will fill @timeout with
+ * more precise value.
+ */
+QTAILQ_FOREACH(slirp, slirp_instances, entry) {
+if (slirp-time_fasttimo) {
+*timeout = TIMEOUT_FAST;
+return;
+}
+if (slirp-do_slowtimo) {
+t = MIN(TIMEOUT_SLOW, t);
+}
 }
+*timeout = t;
 }
 
-void slirp_pollfds_fill(GArray *pollfds)
+void slirp_pollfds_fill(GArray *pollfds, uint32_t *timeout)
 {
 Slirp *slirp;
 struct socket *so, *so_next;
@@ -439,6 +458,7 @@ void slirp_pollfds_fill(GArray *pollfds)
 }
 }
 }
+slirp_update_timeout(timeout);
 }
 
 void slirp_pollfds_poll(GArray *pollfds, int select_error)
diff --git a/stubs/slirp.c b/stubs/slirp.c
index f1fc833..bd0ac7f 100644
--- a/stubs/slirp.c
+++ b/stubs/slirp.c
@@ -1,11 +1,7 @@
 #include qemu-common.h
 #include slirp/slirp.h
 
-void slirp_update_timeout(uint32_t *timeout)
-{
-}
-
-void slirp_pollfds_fill(GArray *pollfds)
+void slirp_pollfds_fill(GArray *pollfds, uint32_t *timeout)
 {
 }
 
-- 
1.8.1.4




[Qemu-devel] [PATCH v4 2/3] slirp: define timeout as macro

2013-08-24 Thread Liu Ping Fan
Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com
---
 slirp/slirp.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/slirp/slirp.c b/slirp/slirp.c
index b71c617..c47af8f 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -47,6 +47,11 @@ static QTAILQ_HEAD(slirp_instances, Slirp) slirp_instances =
 static struct in_addr dns_addr;
 static u_int dns_addr_time;
 
+#define TIMEOUT_FAST 2  /* milliseconds */
+#define TIMEOUT_SLOW 499  /* milliseconds */
+/* for the aging of certain requests like DNS */
+#define TIMEOUT_DEFAULT 1000  /* milliseconds */
+
 #ifdef _WIN32
 
 int get_dns_addr(struct in_addr *pdns_addr)
@@ -57,7 +62,7 @@ int get_dns_addr(struct in_addr *pdns_addr)
 IP_ADDR_STRING *pIPAddr;
 struct in_addr tmp_addr;
 
-if (dns_addr.s_addr != 0  (curtime - dns_addr_time)  1000) {
+if (dns_addr.s_addr != 0  (curtime - dns_addr_time)  TIMEOUT_DEFAULT) {
 *pdns_addr = dns_addr;
 return 0;
 }
@@ -113,7 +118,7 @@ int get_dns_addr(struct in_addr *pdns_addr)
 
 if (dns_addr.s_addr != 0) {
 struct stat old_stat;
-if ((curtime - dns_addr_time)  1000) {
+if ((curtime - dns_addr_time)  TIMEOUT_DEFAULT) {
 *pdns_addr = dns_addr;
 return 0;
 }
@@ -260,7 +265,7 @@ void slirp_cleanup(Slirp *slirp)
 void slirp_update_timeout(uint32_t *timeout)
 {
 if (!QTAILQ_EMPTY(slirp_instances)) {
-*timeout = MIN(1000, *timeout);
+*timeout = MIN(TIMEOUT_DEFAULT, *timeout);
 }
 }
 
@@ -452,11 +457,13 @@ void slirp_pollfds_poll(GArray *pollfds, int select_error)
 /*
  * See if anything has timed out
  */
-if (slirp-time_fasttimo  ((curtime - slirp-time_fasttimo) = 2)) {
+if (slirp-time_fasttimo 
+((curtime - slirp-time_fasttimo) = TIMEOUT_FAST)) {
 tcp_fasttimo(slirp);
 slirp-time_fasttimo = 0;
 }
-if (slirp-do_slowtimo  ((curtime - slirp-last_slowtimo) = 499)) {
+if (slirp-do_slowtimo 
+((curtime - slirp-last_slowtimo) = TIMEOUT_SLOW)) {
 ip_slowtimo(slirp);
 tcp_slowtimo(slirp);
 slirp-last_slowtimo = curtime;
-- 
1.8.1.4




[Qemu-devel] [PATCH 1/2] hpet: entitle more irq pins for hpet

2013-08-24 Thread Liu Ping Fan
On PC, IRQ2/8 can be reserved for hpet timer 0/1. And pin 16~23 of
ioapic can be dynamically assigned to hpet as guest chooses.

Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com
---
 hw/timer/hpet.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index 648b383..cd95d39 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -41,6 +41,8 @@
 #endif
 
 #define HPET_MSI_SUPPORT0
+/* Hpet can use non-legacy IRQ16~23, and an IRQ2 ,IRQ8 */
+#define HPET_TN_INT_CAP (0xff0104ULL  32)
 
 #define TYPE_HPET hpet
 #define HPET(obj) OBJECT_CHECK(HPETState, (obj), TYPE_HPET)
@@ -653,8 +655,8 @@ static void hpet_reset(DeviceState *d)
 if (s-flags  (1  HPET_MSI_SUPPORT)) {
 timer-config |= HPET_TN_FSB_CAP;
 }
-/* advertise availability of ioapic inti2 */
-timer-config |=  0x0004ULL  32;
+/* advertise availability of ioapic int */
+timer-config |=  HPET_TN_INT_CAP;
 timer-period = 0ULL;
 timer-wrap_flag = 0;
 }
-- 
1.8.1.4




[Qemu-devel] [PATCH 2/2] hpet: inverse polarity when pin above ISA_NUM_IRQS

2013-08-24 Thread Liu Ping Fan
According to hpet spec, hpet irq is high active. But according to
ICH spec, there is inversion before the input of ioapic. So the OS
will expect low active on this IRQ line.(And this is observed on
bare metal).

We fold the emulation of this inversion inside the hpet logic.

Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com
---
kernel has a bug with ioapic, refer to
   https://lkml.org/lkml/2013/8/23/98
With all these patch, linux-2.6/Documentation/timers/hpet_example.c can work
on qemu 
---
 hw/timer/hpet.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index cd95d39..a6626e2 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -200,13 +200,23 @@ static void update_irq(struct HPETTimer *timer, int set)
 if (!set || !timer_enabled(timer) || !hpet_enabled(timer-state)) {
 s-isr = ~mask;
 if (!timer_fsb_route(timer)) {
-qemu_irq_lower(s-irqs[route]);
+/* fold the ICH PIRQ# pin's internal inversion logic into hpet */
+if (route = ISA_NUM_IRQS) {
+qemu_irq_raise(s-irqs[route]);
+} else {
+qemu_irq_lower(s-irqs[route]);
+}
 }
 } else if (timer_fsb_route(timer)) {
 stl_le_phys(timer-fsb  32, timer-fsb  0x);
 } else if (timer-config  HPET_TN_TYPE_LEVEL) {
 s-isr |= mask;
-qemu_irq_raise(s-irqs[route]);
+/* fold the ICH PIRQ# pin's internal inversion logic into hpet */
+if (route = ISA_NUM_IRQS) {
+qemu_irq_lower(s-irqs[route]);
+} else {
+qemu_irq_raise(s-irqs[route]);
+}
 } else {
 s-isr = ~mask;
 qemu_irq_pulse(s-irqs[route]);
-- 
1.8.1.4




Re: [Qemu-devel] Disable scaling of SDL

2013-08-24 Thread Taimoor Mirza
Hi Stefan,

Thanks for your reply. Is there any way I can disable scaling in SDL
library? I've not used SDL before and I am not sure whether there is
some configuration option for it or not?

-Taimoor

On Sat, Aug 24, 2013 at 11:47 PM, Stefan Weil s...@weilnetz.de wrote:
 Am 24.08.2013 15:43, schrieb Taimoor Mirza:
 Hi guys,

 I am using QEMU with SDL support to run some demo applications.
 Problem I am facing is that fonts in my SDL window are not displayed
 properly. I have to press Ctrl+Alt+u to undo scaling. After that fonts
 display correctly.
 Is there any way I can disable scaling in SDL window?

 Thanks,
 Taimoor

 Hi Taimoor,

 currently the only way to disable scaling is modifying the
 source code and building your own binaries.

 SDL scaling is indeed not useful, uses broken code for
 all platforms and scales without reason on Windows host.

 http://patchwork.ozlabs.org/patch/155925/ is a patch
 which disables it.

 Regards,
 Stefan