[Qemu-devel] QEMU development for MIPS64 user mode

2011-03-29 Thread Khansa Butt
hi
I have added support for MIPS64 user mode emulation in QEMU and email git
patch to the qemu-devel mailing list
but I got no any response yet. My Patch mail has the following subject line
MIPS64 user mode emulation Patch
please verify that this patch mail is not neglected or guide me towards the
proper way of patch submitting.


Re: [Qemu-devel] [PATCH v24 00/10] usb-ccid

2011-03-29 Thread Jes Sorensen
On 03/28/11 18:11, Alon Levy wrote:
 This patchset adds three new devices, usb-ccid, ccid-card-passthru and
 ccid-card-emulated, providing a CCID bus, a simple passthru protocol
 implementing card requiring a client, and a standalone emulated card.
 
 It also introduces a new directory libcaccard with CAC card emulation,
 CAC is a type of ISO 7816 smart card.
 
 Tree for pull: git://anongit.freedesktop.org/~alon/qemu usb_ccid.v24

Hi Alon,

I looked through v24 and it seems to be addressing the issues that I
raised with v23, so:

Reviewed-by: Jes Sorensen jes.soren...@redhat.com

Cheers,
Jes



Re: [Qemu-devel] [PATCH 27/27] Add SLOF-based partition firmware for pSeries machine, allowing more boot options

2011-03-29 Thread David Gibson
On Mon, Mar 28, 2011 at 08:13:04AM -0500, Anthony Liguori wrote:
 On 03/27/2011 08:19 PM, David Gibson wrote:
 We should pull in SLOF via a git submodule.  That ensures we ship
 the source code along with the binary.
 Um, ok.  Do I need to do anything about this?
 
 We should introduce SLOF as one patch that adds the git submodule
 and the binary.
 
 The best way to do this is for me to pull as binary diffs on the
 list kind of suck.
 
 But before we do the git submodule, I need to mirror SLOF on
 qemu.org such that everything can be fetched from one place.  Ping
 me later today when you get online and I'll explain how to do the
 git submodule part.

Sorry, I slept badly last night and wasn't up until after you'd gone.
Can you email the instructions instead.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson



Re: [Qemu-devel] [PATCH v2] Do not delete BlockDriverState when deleting the drive

2011-03-29 Thread Markus Armbruster
Ryan Harper ry...@us.ibm.com writes:

 * Markus Armbruster arm...@redhat.com [2011-03-24 07:27]:
 Whoops, almost missed this.  Best to cc: me to avoid that.
 

 It was sent directly to you:

   Sender: qemu-devel-bounces+ryanh=us.ibm@nongnu.org
   From: Ryan Harper ry...@us.ibm.com
   Subject: Re: [Qemu-devel] [PATCH v2] Do not delete BlockDriverState when 
 deleting the drive
   Date: Tue, 22 Mar 2011 20:53:47 -0500
   Message-ID: 20110323015347.ga20...@us.ibm.com
   User-Agent: Mutt/1.5.6+20040907i
   To: Markus Armbruster arm...@redhat.com
   Cc: Kevin Wolf kw...@redhat.com, Ryan Harper ry...@us.ibm.com,
   qemu-devel@nongnu.org

Indeed.  Best to cc: me *and* to ping me when the cc: doesn't get a
timely response.  Thanks!

[...]



[Qemu-devel] Re: [PATCH 3/4] Introduce machine state

2011-03-29 Thread Paolo Bonzini

On 03/28/2011 07:21 PM, Blue Swirl wrote:


  What's the distinction between vm state and machine state?


VM state should be invisible (except for PV devices).


Got it.  That's why I called it emulator state (a bit generic, but 
more precise than vm state: vm_clock for example is guest-visible).



About 'machine', I was thinking about -M switch to specify
the emulated machine type.


Yes, makes sense.  I actually like the name machine state, as long as 
you rename what you called virtual machine state.


Paolo



[Qemu-devel] [PATCH repost] qemu-img: Initial progress printing support

2011-03-29 Thread Jes . Sorensen
From: Jes Sorensen jes.soren...@redhat.com

This adds the basic infrastructure for supporting progress output
on the command line, as well as progress support for qemu-img commands
'rebase' and 'convert'.

Signed-off-by: Jes Sorensen jes.soren...@redhat.com
---
 Makefile.objs|2 +-
 qemu-common.h|5 +++
 qemu-img-cmds.hx |4 +-
 qemu-img.c   |   38 -
 qemu-progress.c  |   94 ++
 5 files changed, 138 insertions(+), 5 deletions(-)
 create mode 100644 qemu-progress.c

diff --git a/Makefile.objs b/Makefile.objs
index f8cf199..6bccea7 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -14,7 +14,7 @@ oslib-obj-$(CONFIG_POSIX) += oslib-posix.o
 # block-obj-y is code used by both qemu system emulation and qemu-img
 
 block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o 
async.o
-block-obj-y += nbd.o block.o aio.o aes.o qemu-config.o
+block-obj-y += nbd.o block.o aio.o aes.o qemu-config.o qemu-progress.o
 block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 
diff --git a/qemu-common.h b/qemu-common.h
index 7a96dd1..a3a4dde 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -330,6 +330,11 @@ void qemu_iovec_memset(QEMUIOVector *qiov, int c, size_t 
count);
 void qemu_iovec_memset_skip(QEMUIOVector *qiov, int c, size_t count,
 size_t skip);
 
+void qemu_init_progress(int enabled, float min_skip);
+void qemu_progress_end(void);
+void qemu_progress_print(float percent, int max);
+int qemu_progress_get_current(void);
+
 /* Convert a byte between binary and BCD.  */
 static inline uint8_t to_bcd(uint8_t val)
 {
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
index 6c7176f..3072d38 100644
--- a/qemu-img-cmds.hx
+++ b/qemu-img-cmds.hx
@@ -28,7 +28,7 @@ STEXI
 ETEXI
 
 DEF(convert, img_convert,
-convert [-c] [-f fmt] [-O output_fmt] [-o options] [-s snapshot_name] 
filename [filename2 [...]] output_filename)
+convert [-c] [-p] [-f fmt] [-O output_fmt] [-o options] [-s 
snapshot_name] filename [filename2 [...]] output_filename)
 STEXI
 @item convert [-c] [-f @var{fmt}] [-O @var{output_fmt}] [-o @var{options}] [-s 
@var{snapshot_name}] @var{filename} [@var{filename2} [...]] 
@var{output_filename}
 ETEXI
@@ -46,7 +46,7 @@ STEXI
 ETEXI
 
 DEF(rebase, img_rebase,
-rebase [-f fmt] [-u] -b backing_file [-F backing_fmt] filename)
+rebase [-f fmt] [-p] [-u] -b backing_file [-F backing_fmt] filename)
 STEXI
 @item rebase [-f @var{fmt}] [-u] -b @var{backing_file} [-F @var{backing_fmt}] 
@var{filename}
 ETEXI
diff --git a/qemu-img.c b/qemu-img.c
index 7e3cc4c..eadeebb 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -77,6 +77,7 @@ static void help(void)
   match exactly. The image doesn't need a working backing 
file before\n
   rebasing in this case (useful for renaming the backing 
file)\n
  '-h' with or without a command shows this help and lists the 
supported formats\n
+ '-p' show progress of command (only certain commands)\n
\n
Parameters to snapshot subcommand:\n
  'snapshot' is the name of the snapshot to create, apply or 
delete\n
@@ -567,6 +568,7 @@ static int compare_sectors(const uint8_t *buf1, const 
uint8_t *buf2, int n,
 static int img_convert(int argc, char **argv)
 {
 int c, ret = 0, n, n1, bs_n, bs_i, compress, cluster_size, cluster_sectors;
+int progress = 0;
 const char *fmt, *out_fmt, *out_baseimg, *out_filename;
 BlockDriver *drv, *proto_drv;
 BlockDriverState **bs = NULL, *out_bs = NULL;
@@ -579,13 +581,14 @@ static int img_convert(int argc, char **argv)
 QEMUOptionParameter *out_baseimg_param;
 char *options = NULL;
 const char *snapshot_name = NULL;
+float local_progress;
 
 fmt = NULL;
 out_fmt = raw;
 out_baseimg = NULL;
 compress = 0;
 for(;;) {
-c = getopt(argc, argv, f:O:B:s:hce6o:);
+c = getopt(argc, argv, f:O:B:s:hce6o:p);
 if (c == -1) {
 break;
 }
@@ -620,6 +623,9 @@ static int img_convert(int argc, char **argv)
 case 's':
 snapshot_name = optarg;
 break;
+case 'p':
+progress = 1;
+break;
 }
 }
 
@@ -642,6 +648,9 @@ static int img_convert(int argc, char **argv)
 goto out;
 }
 
+qemu_init_progress(progress, 2.0);
+qemu_progress_print(0, 100);
+
 bs = qemu_mallocz(bs_n * sizeof(BlockDriverState *));
 
 total_sectors = 0;
@@ -773,6 +782,11 @@ static int img_convert(int argc, char **argv)
 }
 cluster_sectors = cluster_size  9;
 sector_num = 0;
+
+nb_sectors = total_sectors - sector_num;
+local_progress = (float)100 /
+(nb_sectors / MIN(nb_sectors, (cluster_sectors)));
+
 for(;;) {
 int64_t bs_num;
 int remainder;
@@ -832,6 +846,7 @@ 

Re: [Qemu-devel] [PATCH 16/17] s390x: translate engine for s390x CPU

2011-03-29 Thread Alexander Graf

On 28.03.2011, at 17:40, Peter Maydell wrote:

 On 24 March 2011 15:58, Alexander Graf ag...@suse.de wrote:
 diff --git a/target-s390x/translate.c b/target-s390x/translate.c
 
 +typedef struct DisasContext DisasContext;
 +struct DisasContext {
 +uint64_t pc;
 +int is_jmp;
 +enum cc_op cc_op;
 +CPUS390XState *env;
 +struct TranslationBlock *tb;
 +};
 
 I don't think anything actually uses dc-env, does it?
 (I like the way that almost none of the translate.c code
 gets a CPUState pointer, makes it hard to accidentally write
 buggy code that relies on things not in the tb_flags.)

Good idea :)

 
 +static char cpu_reg_names[10*3 + 6*4];
 
 I can see code ins390x_translate_init() which sets this up, but
 I can't see anything which uses it?

It's used during the setup (and needs to be kept alive after that - hence the 
global):

p = cpu_reg_names;
for (i = 0; i  16; i++) {
snprintf(p, cpu_reg_names_size, r%d, i);
regs[i] = tcg_global_mem_new(TCG_AREG0,
 offsetof(CPUState, regs[i]), p);
p += (i  10) ? 3 : 4;
cpu_reg_names_size -= (i  10) ? 3 : 4;
}


 
 +#if 0  /* reads four when it should read only 3 */
 +case 2:
 
 Is there any point having #if'd out broken code?
 Either fix it and enable it, or just have a comment
 to the effect that we could have optimised versions
 for cases 2, 4, 5, 6 but currently do not.

I wanted to keep it in as documentation. But yeah, might make sense to just 
remove it.

 
 +case 0x4:  /* LMG  R1,R3,D2(B2) [RSE] */
 +case 0x24: /* STMG R1,R3,D2(B2) [RSE] */
 +case 0x26: /* STMH R1,R3,D2(B2) [RSE] */
 +case 0x96: /* LMH  R1,R3,D2(B2) [RSE] */
 +/* Apparently, unrolling lmg/stmg of any size gains performance -
 +   even for very long ones... */
 
 Doesn't this take you over MAX_OP_PER_INSTR for some cases?

I haven't encountered any case where it does.

 
 +tmp2 = tcg_const_i64uint64_t)i2)  48) | 
 0xULL);
 
 This line is over 80 chars, as are a handful of others in this file.

Yeah, I generally see the 80 char limit as soft limit and make it hard on ~90. 
If a line is only over it by very little, readability doesn't improve by 
breaking it up. So far, everyone agreed to that approach :).

 
 +case 0xa: /* SVCI [RR] */
 +insn = ld_code2(s-pc);
 +debug_insn(insn);
 +i = insn  0xff;
 +#ifdef CONFIG_USER_ONLY
 +s-pc += 2;
 +#endif
 +update_psw_addr(s);
 +gen_op_calc_cc(s);
 
 Why do we only need to update s-pc if CONFIG_USER_ONLY?
 Not saying it's wrong, but it could use an explanatory comment...

The user code needs to know where it jumps back to, while the exception 
generation code needs to get the exact position it was in to generate some more 
metadata. I'm not sure a comment really would be helpful here - it's an 
implementation detail that is hard to explain properly in a few words.


Alex




Re: [Qemu-devel] MIPS64 user mode emulation Patch

2011-03-29 Thread Riku Voipio
Hi,

First, do you have some instructions on howto build Octeon usermode
64bit binaries. Second, I think we would prefer that the patch was split
to smaller patches. At least the target-mips changes should be a separate
patch.

Some more comments included inline between the code.

On Sat, Mar 26, 2011 at 11:58:37AM +0500, Khansa Butt wrote:
 From cd88be1263d0fc9802cd4dd358ed0299c0d106b0 Mon Sep 17 00:00:00 2001
 From: Khansa Butt  Ehsan-ul-Haq kha...@kics.edu.pk
 Date: Sat, 26 Mar 2011 11:53:11 +0500
 Subject: [PATCH] MIPS64 user mode emulation in QEMU
  This patch adds support for Cavium Network's
  Octeon 57XX user mode instructions.  Octeon
  57xx is based on MIPS64.  So this patch is
  the first MIPS64 User Mode Emulation in QEMU
  This is the team(Khansa Butt, Ehsan-ul-Haq, Abdul Qadeer, Abdul Waheed)
  work of HPCNL Lab at KICS-UET Lahore.
 
 
 Signed-off-by: Khansa Butt kha...@kics.edu.pk
 ---
  configure |1 +
  default-configs/mips64-linux-user.mak |1 +
  exec.c|1 +
  linux-user/elfload.c  |   15 +-
  linux-user/main.c |   20 +-
  linux-user/mips64/syscall.h   |2 +
  linux-user/signal.c   |3 +-
  linux-user/syscall.c  |2 +
  target-mips/cpu.h |   16 +
  target-mips/translate.c   |  659
 -
  10 files changed, 704 insertions(+), 16 deletions(-)
  create mode 100644 default-configs/mips64-linux-user.mak
 
 diff --git a/configure b/configure
 index 438219b..045a4ef 100755
 --- a/configure
 +++ b/configure
 @@ -1011,6 +1011,7 @@ cris-linux-user \
  m68k-linux-user \
  microblaze-linux-user \
  mips-linux-user \
 +mips64-linux-user \
  mipsel-linux-user \
  ppc-linux-user \
  ppc64-linux-user \
 diff --git a/default-configs/mips64-linux-user.mak
 b/default-configs/mips64-linux-user.mak
 new file mode 100644
 index 000..1598bfc
 --- /dev/null
 +++ b/default-configs/mips64-linux-user.mak
 @@ -0,0 +1 @@
 +# Default configuration for mips64-linux-user
 diff --git a/exec.c b/exec.c
 index 49c28b1..ee3f78e 100644
 --- a/exec.c
 +++ b/exec.c
 @@ -2441,6 +2441,7 @@ int page_check_range(target_ulong start, target_ulong
 len, int flags)
  for (addr = start, len = end - start;
   len != 0;
   len -= TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) {
 +addr  = qemu_host_page_mask;
  p = page_find(addr  TARGET_PAGE_BITS);

Are you sure this will not generate ill effect on other target/host architecture
combinations?

  if( !p )
  return -1;
 diff --git a/linux-user/elfload.c b/linux-user/elfload.c
 index 33d776d..60fe85e 100644
 --- a/linux-user/elfload.c
 +++ b/linux-user/elfload.c
 @@ -16,6 +16,8 @@
  #include qemu.h
  #include disas.h
 
 +extern int TARGET_OCTEON;
 +
  #ifdef _ARCH_PPC64
  #undef ARCH_DLINFO
  #undef ELF_PLATFORM
 @@ -25,6 +27,9 @@
  #undef ELF_ARCH
  #endif
 
 +#define EF_MIPS_MARCH 16711680
 +#define E_MIPS_MACH_OCTEON 9109504
 +

please use hexadecimal values.

  #define ELF_OSABI   ELFOSABI_SYSV
 
  /* from personality.h */
 @@ -1313,7 +1318,7 @@ static void load_elf_image(const char *image_name, int
 image_fd,
  vaddr_po = TARGET_ELF_PAGEOFFSET(vaddr);
  vaddr_ps = TARGET_ELF_PAGESTART(vaddr);
 
 -error = target_mmap(vaddr_ps, eppnt-p_filesz + vaddr_po,
 +error = target_mmap(vaddr_ps, eppnt-p_memsz + vaddr_po,
  elf_prot, MAP_PRIVATE | MAP_FIXED,
  image_fd, eppnt-p_offset - vaddr_po);
  if (error == -1) {
 @@ -1588,7 +1593,13 @@ int load_elf_binary(struct linux_binprm * bprm,
 struct target_pt_regs * regs,
 If we do nothing, we'll have overwritten this when we re-use
 bprm-buf
 when we load the interpreter.  */
  elf_ex = *(struct elfhdr *)bprm-buf;
 -
 +#if defined(TARGET_MIPS64)
 +if ((elf_ex.e_flags  EF_MIPS_MARCH) == E_MIPS_MACH_OCTEON) {
 +TARGET_OCTEON = 1;
 +} else {
 +TARGET_OCTEON = 0;
 +}
 +#endif
  bprm-p = copy_elf_strings(1, bprm-filename, bprm-page, bprm-p);
  bprm-p = copy_elf_strings(bprm-envc,bprm-envp,bprm-page,bprm-p);
  bprm-p = copy_elf_strings(bprm-argc,bprm-argv,bprm-page,bprm-p);
 diff --git a/linux-user/main.c b/linux-user/main.c
 index 0d627d6..8b4b90b 100644
 --- a/linux-user/main.c
 +++ b/linux-user/main.c
 @@ -1937,10 +1937,16 @@ static int do_store_exclusive(CPUMIPSState *env)
  int d;
 
  addr = env-lladdr;
 +/* 64 bit address is converted to 32 bit value so that a valid
 +* l1_map value can be accessed. This thing is needed for target
 +* mips64 and host 32 bit x86
 +*/
 +addr = qemu_host_page_mask;

same as earlier.

  page_addr = addr  TARGET_PAGE_MASK;
  start_exclusive();
  mmap_lock();
  flags = page_get_flags(page_addr);
 +addr = env-lladdr;
  if 

Re: [Qemu-devel] [PATCH v3] Do not delete BlockDriverState when deleting the drive

2011-03-29 Thread Markus Armbruster
Since you have to respin anyway, would you mind limiting commit message
line length to 70-75 characters?  Thanks.



Re: [Qemu-devel] [PATCH 14/17] s390x: Implement opcode helpers

2011-03-29 Thread Alexander Graf

On 28.03.2011, at 19:55, Peter Maydell wrote:

 On 28 March 2011 18:23, Alexander Graf ag...@suse.de wrote:
 On 03/24/2011 06:29 PM, Peter Maydell wrote:
 +/* condition codes for binary FP ops */
 +static uint32_t set_cc_f32(float32 v1, float32 v2)
 +{
 +if (float32_is_any_nan(v1) || float32_is_any_nan(v2)) {
 +return 3;
 +} else if (float32_eq(v1, v2,env-fpu_status)) {
 +return 0;
 +} else if (float32_lt(v1, v2,env-fpu_status)) {
 +return 1;
 +} else {
 +return 2;
 +}
 +}
 
 Can you not use float32_compare_quiet() (returns a value
 telling you if it's less/equal/greater/unordered)?
 If not, needs a comment saying why you need to do it the hard way.
 
 I just checked the macros there and it looks like float32_compare_quiet
 returns eq when both numbers are NaN.
 
 Hmm?
 
if (( ( extractFloat ## s ## Exp( a ) == nan_exp ) \
 extractFloat ## s ## Frac( a ) ) || \
( ( extractFloat ## s ## Exp( b ) == nan_exp ) \
  extractFloat ## s ## Frac( b ) )) {\
if (!is_quiet || \
float ## s ## _is_signaling_nan( a ) ||  \
float ## s ## _is_signaling_nan( b ) ) { \
float_raise( float_flag_invalid STATUS_VAR); \
}\
return float_relation_unordered; \
}\
 
 If A is a NaN (ie its exponent is nan_exp and the frac bits aren't zero)
 or B is a NaN then we return float_relation_unordered.
 
 We would still have to convert from
 the return value from that over to a CC value. I honestly don't see any
 benefit - the code doesn't become cleaner or smaller.
 
 So you get
 static uint32_t set_cc_f32(float32 v1, float32 v2)
 {
switch (float32_compare_quiet(v1, v2, env-fpu_status)) {
case float_relation_unordered:
return 3;
case float_relation_equal:
return 0;
case float_relation_less:
return 1;
case float_relation_greater:
return 2;
case float_relation_unordered:
return 3;
}
 }
 
 (and you probably want to put the conversion switch into a function
 since you'll be using it several times.)
 
 Which I think is pretty straightforward, cleaner because we only
 call one softfloat function rather than several, and should be
 faster too (we get to avoid repeating a pile of tedious bit manipulation
 in the eq and lt functions).

Alrighty, changed the code :).

 
 +/* load 128-bit FP zero */
 +void HELPER(lzxr)(uint32_t f1)
 +{
 +CPU_QuadU x;
 +x.q = float64_to_float128(float64_zero,env-fpu_status);
 
 Yuck. Just define a float128_zero if we need one.
 
 Good point. Mind to do so? I find myself struggling with the code there.
 
 We could just follow the pattern of  float128_default_nan_{low,high}
 in softfloat.h:
 
 #define float128_zero_low LIT64(0)
 #define float128_zero_high LIT64(0)
 
 then your function has:
 x.q.high = float128_zero_high;
 x.q.low = float128_zero_low;
 
 Or we could do something with an expression that returns a
 struct type; that would be cleaner. I think the default nan
 code is assuming it might have to be compiled with something
 other than gcc. However I forget the C syntax and have to go
 home now :-)

I'll just leave it to you for a follow-up patch :). The less I have to touch in 
softfpu code, the better :)


Alex




Re: [Qemu-devel] [PATCH 27/27] Add SLOF-based partition firmware for pSeries machine, allowing more boot options

2011-03-29 Thread Alexander Graf

On 28.03.2011, at 20:02, Anthony Liguori wrote:

 On 03/28/2011 12:42 PM, Blue Swirl wrote:
 On Mon, Mar 28, 2011 at 4:16 PM, Anthony Liguorianth...@codemonkey.ws  
 wrote:
 On 03/28/2011 04:03 AM, Alexander Graf wrote:
 Um, ok.  Do I need to do anything about this?
 I'm also not sure this is too important.
 It's GPL compliance so yes, it's very important.
 
  Most of our firmware blobs come from svn repos which can't be submoduled.
 The only firmware blob we're not currently including as a git submodule is
 OpenBIOS.
 No, there's also OpenHack'Ware (ppc_rom.bin) and s390-zipl.rom.
 
 Alex, what's the source of zipl?

See the README file :P.

  git://repo.or.cz/s390-tools.git virtio-zipl


Alex




Re: [Qemu-devel] [PATCH 27/27] Add SLOF-based partition firmware for pSeries machine, allowing more boot options

2011-03-29 Thread Alexander Graf

On 28.03.2011, at 21:52, Aurelien Jarno wrote:

 On Mon, Mar 28, 2011 at 01:50:40PM -0500, Anthony Liguori wrote:
 On 03/28/2011 01:24 PM, Aurelien Jarno wrote:
 On Mon, Mar 28, 2011 at 01:02:45PM -0500, Anthony Liguori wrote:
 On 03/28/2011 12:42 PM, Blue Swirl wrote:
 On Mon, Mar 28, 2011 at 4:16 PM, Anthony Liguorianth...@codemonkey.ws   
 wrote:
 On 03/28/2011 04:03 AM, Alexander Graf wrote:
 Um, ok.  Do I need to do anything about this?
 I'm also not sure this is too important.
 It's GPL compliance so yes, it's very important.
 
 Most of our firmware blobs come from svn repos which can't be 
 submoduled.
 The only firmware blob we're not currently including as a git submodule 
 is
 OpenBIOS.
 No, there's also OpenHack'Ware (ppc_rom.bin) and s390-zipl.rom.
 Alex, what's the source of zipl?
 
 I believe the main reason is that different boards use different
 commits so a single submodule is a bit challenge.  We probably ought to
 figure something out here though for the next release.
 
 Can anyone comment a bit more about OpenBIOS?
 
 BTW, OpenBIOS is already actively mirrored on git.qemu.org so all that's
 needed is a patch that does a git submodule add with the appropriate 
 commit.
 That would be an improvement. Though building various OpenBIOS images
 depends on appropriate cross compilers. The situation is actually same
 as with SeaBIOS.
 Can you do a git submodule add then?
 
 And as long as we don't have a consistent policy about it, we can just 
 as
 well stick with the README file.
 We do have a consistent policy :-)  We're just not enforcing it as 
 tightly
 as we should.
 
 Any binary we ship in the release tgz's should also have corresponding
 source in a submodule.
 What about OpenHack'Ware (and PReP machine), should it be deleted?
 Yes.  I don't think the source for that is available, correct?  I
 don't think we have any other choice.
 
 Debian still holds a copy of the code.
 
 I had thought that the actual binary was from Jocelyn and contains
 patches that noone else has.  In fact, the last commit is:
 
 commit 55aa45ddde3283cdd781326d001f7456bf02f684
 Author: j_mayer j_mayer@c046a42c-6fe2-441c-8c8c-71466251a162
 Date:   Mon Oct 1 06:44:33 2007 +
 
Quickly hack PowerPC BIOS able to boot on CDROM again.
 
 People have worked recently to
 restore prep support that has been broken by various patches, it would
 be a pitty to remove it without before asking them.
 
 I'd be very happy to just submodule whatever sources Debian is using.
 
 
 I am not sure that it corresponds to the latest code, so it might have
 some issues, but at least it is something that is usable. The code is a
 vailable from:
 
 http://ftp.debian.org/debian/pool/main/o/openhackware/
 
 Note that the .diff.gz contains a few patches needed to fix build
 issues.

I really wouldn't want to see PREP getting removed, now that we have a 
maintainer for it again :). It might be a good idea to recompile the binary we 
ship from that source though?


Alex




Re: [Qemu-devel] [PATCH 16/17] s390x: translate engine for s390x CPU

2011-03-29 Thread Peter Maydell
On 29 March 2011 09:55, Alexander Graf ag...@suse.de wrote:

 On 28.03.2011, at 17:40, Peter Maydell wrote:

 On 24 March 2011 15:58, Alexander Graf ag...@suse.de wrote:
 diff --git a/target-s390x/translate.c b/target-s390x/translate.c
 +    case 0x4:  /* LMG      R1,R3,D2(B2)     [RSE] */
 +    case 0x24: /* STMG     R1,R3,D2(B2)     [RSE] */
 +    case 0x26: /* STMH     R1,R3,D2(B2)     [RSE] */
 +    case 0x96: /* LMH      R1,R3,D2(B2)     [RSE] */
 +        /* Apparently, unrolling lmg/stmg of any size gains performance -
 +           even for very long ones... */

 Doesn't this take you over MAX_OP_PER_INSTR for some cases?

 I haven't encountered any case where it does.

Really? MAX_OP_PER_INSTR's only 96, so if you have 16 registers
in your loop then it only needs 6 ops per register to hit that,
and the op 0x96 case looks like it must generate more than that.

I have an item on my todo list to see if I can add an assert()
check for this limit, because there are cases for Neon load/stores
that apparently hit it.

 +            tmp2 = tcg_const_i64uint64_t)i2)  48) | 
 0xULL);

 This line is over 80 chars, as are a handful of others in this file.

 Yeah, I generally see the 80 char limit as soft limit and make it
 hard on ~90. If a line is only over it by very little, readability
 doesn't improve by breaking it up. So far, everyone agreed to that
 approach :).

80 chars reduces readability for me because I have emacs configured
to make long lines look very ugly so I don't write them :-)

Also, if we want the standard to be 'soft 80, hard 90' we should
say so in CODING_STYLE...

 +    case 0xa: /* SVC    I         [RR] */
 +        insn = ld_code2(s-pc);
 +        debug_insn(insn);
 +        i = insn  0xff;
 +#ifdef CONFIG_USER_ONLY
 +        s-pc += 2;
 +#endif
 +        update_psw_addr(s);
 +        gen_op_calc_cc(s);

 Why do we only need to update s-pc if CONFIG_USER_ONLY?
 Not saying it's wrong, but it could use an explanatory comment...

 The user code needs to know where it jumps back to, while the
 exception generation code needs to get the exact position it was
 in to generate some more metadata.

Ah. For ARM we do this by advancing env-regs[15] in linux-user/main.c
cpu_loop() when we get an EXCP_SWI. It looks like we do it that way
for MIPS and SPARC at least too, so I guess it would be better for
s390 to follow that pattern.

-- PMM



[Qemu-devel] Re: [PATCH 0/2] avoid races on exec migration

2011-03-29 Thread Paolo Bonzini

On 03/21/2011 09:24 AM, Paolo Bonzini wrote:

On 03/09/2011 06:21 PM, Paolo Bonzini wrote:

QEMU has a sigchld handler that reaps any child process. -smb is the
only user of it and, in fact, QEMU inherited it from slirp. However,
this handler causes 'exec' based migration to randomly return 'status:
failed' in the monitor. This happens when the signal handler for SIGCHLD
is ran before the pclose() of exec migration.

The return status of fclose() is passed back as return status of
qemu_fclose(). If qemu_fclose() fails, then the exec_close() in
migration-exec.c returns a error code. This causes migrate_fd_cleanup()
to return an error, and thus finally we see why 'status: failed' occurs:

if (migrate_fd_cleanup(s) 0) {
if (old_vm_running) {
vm_start();
}
state = MIG_STATE_ERROR;
}

To avoid this, register the pids in a list and, on SIGCHLD, set up a
bottom-half that would go through the pids and reap them.

Since I'm at it, I'm moving iohandler stuff out of vl.c. The new
file isn't a perfect place to add the child watcher, but it's arguably
better than vl.c.

This should be applied to both master and stable.

Paolo Bonzini (2):
extract I/O handler lists to iohandler.c
add a service to reap zombies

Makefile.objs | 2 +-
iohandler.c | 193
+
os-posix.c | 9 ---
qemu-common.h | 4 +
slirp/misc.c | 5 +-
vl.c | 106 ++--
6 files changed, 207 insertions(+), 112 deletions(-)
create mode 100644 iohandler.c



Ping?


Ping^2?

Paolo



Re: [Qemu-devel] [PATCH 16/17] s390x: translate engine for s390x CPU

2011-03-29 Thread Alexander Graf

On 29.03.2011, at 11:17, Peter Maydell wrote:

 On 29 March 2011 09:55, Alexander Graf ag...@suse.de wrote:
 
 On 28.03.2011, at 17:40, Peter Maydell wrote:
 
 On 24 March 2011 15:58, Alexander Graf ag...@suse.de wrote:
 diff --git a/target-s390x/translate.c b/target-s390x/translate.c
 +case 0x4:  /* LMG  R1,R3,D2(B2) [RSE] */
 +case 0x24: /* STMG R1,R3,D2(B2) [RSE] */
 +case 0x26: /* STMH R1,R3,D2(B2) [RSE] */
 +case 0x96: /* LMH  R1,R3,D2(B2) [RSE] */
 +/* Apparently, unrolling lmg/stmg of any size gains performance -
 +   even for very long ones... */
 
 Doesn't this take you over MAX_OP_PER_INSTR for some cases?
 
 I haven't encountered any case where it does.
 
 Really? MAX_OP_PER_INSTR's only 96, so if you have 16 registers
 in your loop then it only needs 6 ops per register to hit that,
 and the op 0x96 case looks like it must generate more than that.
 
 I have an item on my todo list to see if I can add an assert()
 check for this limit, because there are cases for Neon load/stores
 that apparently hit it.

Hrm - might be useful to increase MAX_OP_PER_INSTR then, no?

 
 +tmp2 = tcg_const_i64uint64_t)i2)  48) | 
 0xULL);
 
 This line is over 80 chars, as are a handful of others in this file.
 
 Yeah, I generally see the 80 char limit as soft limit and make it
 hard on ~90. If a line is only over it by very little, readability
 doesn't improve by breaking it up. So far, everyone agreed to that
 approach :).
 
 80 chars reduces readability for me because I have emacs configured
 to make long lines look very ugly so I don't write them :-)

Heh, I have vi configured to color in lines 80 chars as well, so I usually 
only keep them there 

 Also, if we want the standard to be 'soft 80, hard 90' we should
 say so in CODING_STYLE...

*shrug* so far CODING_STYLE has only brought badness to qemu. The new style is 
less readable than the common dominator that was there before (Fabrice's coding 
style) and resulted in man-years of wasted time on rejected patches for the 
sake of braces. I'd rather want to remove the file than patching it (which 
again would create a mail thread of 300 mails, waste 5 man-years of 
productivity and bring us no gain in the end).

 
 +case 0xa: /* SVCI [RR] */
 +insn = ld_code2(s-pc);
 +debug_insn(insn);
 +i = insn  0xff;
 +#ifdef CONFIG_USER_ONLY
 +s-pc += 2;
 +#endif
 +update_psw_addr(s);
 +gen_op_calc_cc(s);
 
 Why do we only need to update s-pc if CONFIG_USER_ONLY?
 Not saying it's wrong, but it could use an explanatory comment...
 
 The user code needs to know where it jumps back to, while the
 exception generation code needs to get the exact position it was
 in to generate some more metadata.
 
 Ah. For ARM we do this by advancing env-regs[15] in linux-user/main.c
 cpu_loop() when we get an EXCP_SWI. It looks like we do it that way
 for MIPS and SPARC at least too, so I guess it would be better for
 s390 to follow that pattern.

Unfortunately, it's not that easy as there are 2 different ways of issuing an 
SVC (actual SVC and EXECUTE instruction), both of which having different 
instruction lengths. So we really need to keep the information in the 
instruction decoder :(


Alex




[Qemu-devel] [Bug 744856] [NEW] can't boot when using more than 6 disks since qemu-kvm-0.13

2011-03-29 Thread Andreas 'ac0v' Specht
Public bug reported:

It's not possible to pass more than 6 disks to a guest since qemu-kvm-0.13 
(also tested with 0.14).
If I pass more than 6 disks (as shown below) the machine complains that their 
is no bootable disk,

The problem occurs with virtio and without virtio.

eg.

/usr/bin/qemu-system-x86_64  --enable-kvm -boot c   -drive
file=/dev/vgr5/fs-01,if=virtio -drive file=/dev/vgr5/fs-
01_srv_workspace,if=virtio -drive file=/dev/vgr5/fs-
01_srv_media,if=virtio -drive file=/dev/vgr5/fs-01_srv_company,if=virtio
-drive file=/dev/vgr5/fs-01_srv_tmp,if=virtio -drive file=/dev/vgr5/fs-
01_srv_download,if=virtio -drive file=/dev/vgr5/fs-
01_srv_share,if=virtio -drive file=/dev/vgr5/fs-01_srv_backup,if=virtio
-drive file=/dev/vgr5/fs-01_srv_private,if=virtio -drive file=/dev/vgr5
/fs-01_srv_build,if=virtio -drive file=/dev/vgr5/fs-01_srv_dev,if=virtio
-drive file=/dev/vgr5/fs-01_srv_backup2,if=virtio -drive file=/dev/vgr5
/fs-01_srv_ftp,if=virtio  -cpu qemu64 -smp 2  -m 4G -append
root=/dev/vda -usbdevice tablet -net
nic,macaddr=90:e6:ba:9d:00:0,model=e1000 -net
tap,ifname=tap0,script=/usr/sbin/qemu-ifup,downscript=/usr/sbin/qemu-
ifdown  -monitor unix:/var/run/kvm/fs-01/monitor,server,nowait -pidfile
/var/run/kvm/fs-01/pid  -k de -kernel
/srv/kvm/kernel/linux-2.6.38-gentoo -append root=/dev/vda -vnc :0 -name
fs-01,process=fs-01 -vga std

** 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/744856

Title:
  can't boot when using more than 6 disks since qemu-kvm-0.13

Status in QEMU:
  New

Bug description:
  It's not possible to pass more than 6 disks to a guest since qemu-kvm-0.13 
(also tested with 0.14).
  If I pass more than 6 disks (as shown below) the machine complains that their 
is no bootable disk,

  The problem occurs with virtio and without virtio.

  eg.

  /usr/bin/qemu-system-x86_64  --enable-kvm -boot c   -drive
  file=/dev/vgr5/fs-01,if=virtio -drive file=/dev/vgr5/fs-
  01_srv_workspace,if=virtio -drive file=/dev/vgr5/fs-
  01_srv_media,if=virtio -drive file=/dev/vgr5/fs-
  01_srv_company,if=virtio -drive file=/dev/vgr5/fs-01_srv_tmp,if=virtio
  -drive file=/dev/vgr5/fs-01_srv_download,if=virtio -drive
  file=/dev/vgr5/fs-01_srv_share,if=virtio -drive file=/dev/vgr5/fs-
  01_srv_backup,if=virtio -drive file=/dev/vgr5/fs-
  01_srv_private,if=virtio -drive file=/dev/vgr5/fs-
  01_srv_build,if=virtio -drive file=/dev/vgr5/fs-01_srv_dev,if=virtio
  -drive file=/dev/vgr5/fs-01_srv_backup2,if=virtio -drive
  file=/dev/vgr5/fs-01_srv_ftp,if=virtio  -cpu qemu64 -smp 2  -m 4G
  -append root=/dev/vda -usbdevice tablet -net
  nic,macaddr=90:e6:ba:9d:00:0,model=e1000 -net
  tap,ifname=tap0,script=/usr/sbin/qemu-ifup,downscript=/usr/sbin/qemu-
  ifdown  -monitor unix:/var/run/kvm/fs-01/monitor,server,nowait
  -pidfile /var/run/kvm/fs-01/pid  -k de -kernel
  /srv/kvm/kernel/linux-2.6.38-gentoo -append root=/dev/vda -vnc :0
  -name fs-01,process=fs-01 -vga std



Re: [Qemu-devel] [PATCH 12/17] s390x: Prepare cpu.h for emulation

2011-03-29 Thread Alexander Graf

On 28.03.2011, at 16:54, Peter Maydell wrote:

 On 24 March 2011 15:58, Alexander Graf ag...@suse.de wrote:
 diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
 
 Minor nits only.
 
 -FPReg fregs[16]; /* FP registers */
 +CPU_DoubleU fregs[16]; /* FP registers */
 
 These changes mean that the FPReg typedef in this file is no longer
 used, so you might as well delete it.

Good point :)

 
 Personally I prefer the way target-arm handles float regs,
 ie it just has 'float64 regs[32]' and relies on them being
 the right representation to pass in registers. This is
 less likely to work with float128s though, and anyway I suspect
 Nathan would disagree with me, so this isn't a request to change
 this code.
 
 +#define EXCP_EXT  1
 +
 +#define EXCP_SVC 2 /* supervisor call (syscall) */
 +#define EXCP_PGM 3 /* program interruption */
 +/* XXX */
 +#define EXCP_EXECUTE_SVC 0xff0 /* supervisor call via execute insn */
 
 This comment ought to have an explanation of what the issue is
 that means it's 'XXX'...

It means this exception shouldn't be referenced in any code, but was at the 
point of putting the XXX in there. I merely forgot to remove it again. Thanks 
for the reminder :).

 
 +CC_OP_ADD_64,   /* */
 +CC_OP_ADDU_64,  /* */
 +CC_OP_SUB_64,   /* */
 +CC_OP_SUBU_64,  /* */
 +CC_OP_ABS_64,   /* */
 +CC_OP_NABS_64,  /* */
 
 Why the empty comments?

Uh - yeah :).

 
 +static inline uint64_t time2tod(uint64_t time) {
 +return (time  9) / 125;
 +}
 
 Could maybe use a comment about what units we're converting
 to and from here.

Yup :)


Alex




Re: [Qemu-devel] [PATCH 1/3] virtio: don't exit on guest errors

2011-03-29 Thread Amit Shah
On (Mon) 28 Mar 2011 [23:14:16], Michael S. Tsirkin wrote:
 When guest does something illegal, such as
 programming invalid index values in the virtio
 device, qemu currently tends to crash.
 
 With virtio, a better idea is to log an error,
 and set status to FAIL which stops the device.
 
 Add an API to do this, and fix core, blk and serial
 to use it on error.
 
 Signed-off-by: Michael S. Tsirkin m...@redhat.com
 ---
  hw/virtio-blk.c|   12 +--
  hw/virtio-serial-bus.c |   13 +--
  hw/virtio.c|   79 
 +++-
  hw/virtio.h|7 +++-
  4 files changed, 73 insertions(+), 38 deletions(-)

ACK

Amit



Re: [Qemu-devel] [PATCH 16/17] s390x: translate engine for s390x CPU

2011-03-29 Thread Peter Maydell
On 29 March 2011 10:25, Alexander Graf ag...@suse.de wrote:
 On 29.03.2011, at 11:17, Peter Maydell wrote:
 On 29 March 2011 09:55, Alexander Graf ag...@suse.de wrote:
 On 28.03.2011, at 17:40, Peter Maydell wrote:
 Doesn't this take you over MAX_OP_PER_INSTR for some cases?

 I haven't encountered any case where it does.

 Really? MAX_OP_PER_INSTR's only 96, so if you have 16 registers
 in your loop then it only needs 6 ops per register to hit that,
 and the op 0x96 case looks like it must generate more than that.

 I have an item on my todo list to see if I can add an assert()
 check for this limit, because there are cases for Neon load/stores
 that apparently hit it.

 Hrm - might be useful to increase MAX_OP_PER_INSTR then, no?

The TCG README suggests that 20 ops is the point at which it's
better to use a helper function. I don't know if that advice
still holds true or not.

 The user code needs to know where it jumps back to, while the
 exception generation code needs to get the exact position it was
 in to generate some more metadata.

 Ah. For ARM we do this by advancing env-regs[15] in linux-user/main.c
 cpu_loop() when we get an EXCP_SWI. It looks like we do it that way
 for MIPS and SPARC at least too, so I guess it would be better for
 s390 to follow that pattern.

 Unfortunately, it's not that easy as there are 2 different ways of
 issuing an SVC (actual SVC and EXECUTE instruction), both of which
 having different instruction lengths. So we really need to keep the
 information in the instruction decoder :(

Does a Linux kernel running on a real s/390 system have to deal with
the distinction in its SVC entrypoint?

-- PMM



Re: [Qemu-devel] [PATCH 16/17] s390x: translate engine for s390x CPU

2011-03-29 Thread Alexander Graf

On 29.03.2011, at 11:56, Peter Maydell wrote:

 On 29 March 2011 10:25, Alexander Graf ag...@suse.de wrote:
 On 29.03.2011, at 11:17, Peter Maydell wrote:
 On 29 March 2011 09:55, Alexander Graf ag...@suse.de wrote:
 On 28.03.2011, at 17:40, Peter Maydell wrote:
 Doesn't this take you over MAX_OP_PER_INSTR for some cases?
 
 I haven't encountered any case where it does.
 
 Really? MAX_OP_PER_INSTR's only 96, so if you have 16 registers
 in your loop then it only needs 6 ops per register to hit that,
 and the op 0x96 case looks like it must generate more than that.
 
 I have an item on my todo list to see if I can add an assert()
 check for this limit, because there are cases for Neon load/stores
 that apparently hit it.
 
 Hrm - might be useful to increase MAX_OP_PER_INSTR then, no?
 
 The TCG README suggests that 20 ops is the point at which it's
 better to use a helper function. I don't know if that advice
 still holds true or not.

Well, the amount of stores / loads stays the same throughout a helper or not. 
The main reason to not use a heavy helper is that all the register values 
need to be flushed out, adding quite substantial overhead for the stores/loads 
on those. When flushing them, tcg also loses its ability to predict which 
values are used, so dead code elimination is moot.

So yes, complex operations that could be optimized by a C compiler should go 
into helpers - preferably if they only use input and output values that get 
passed as registers. As soon as they touch memory or env though, the world 
isn't as great anymore :(.

 
 The user code needs to know where it jumps back to, while the
 exception generation code needs to get the exact position it was
 in to generate some more metadata.
 
 Ah. For ARM we do this by advancing env-regs[15] in linux-user/main.c
 cpu_loop() when we get an EXCP_SWI. It looks like we do it that way
 for MIPS and SPARC at least too, so I guess it would be better for
 s390 to follow that pattern.
 
 Unfortunately, it's not that easy as there are 2 different ways of
 issuing an SVC (actual SVC and EXECUTE instruction), both of which
 having different instruction lengths. So we really need to keep the
 information in the instruction decoder :(
 
 Does a Linux kernel running on a real s/390 system have to deal with
 the distinction in its SVC entrypoint?

An s390 kernel gets the size information as interrupt parameter, so it can 
simply calculate the NIP from that.


Alex




[Qemu-devel] Re: [PATCH V2] hw/xen_disk: ioreq not finished on error

2011-03-29 Thread Stefano Stabellini
On Tue, 29 Mar 2011, Feiran Zheng wrote:
 Bug fix: routines 'ioreq_runio_qemu_sync' and 'ioreq_runio_qemu_aio'
 won't call 'ioreq_unmap' or 'ioreq_finish' on errors, leaving ioreq in
 the blkdev-inflight list and a leak.
 

Acked-by: Stefano Stabellini stefano.stabell...@eu.citrix.com




[Qemu-devel] A question about QEMU on unix

2011-03-29 Thread Bin (Bin) Shi
Can QEMU run on QNX ?

 

My machine is 

Cpu - arm11

Os - qnx6.5

 

Does QEMU support my machine ?

 

Thanks.



[Qemu-devel] qemu-git web viewer?

2011-03-29 Thread Rob Landley
Is there a web viewer for the git repository?

The download page links to http://git.qemu.org/qemu.git but that's 404,
and http://git.qemu.org says I don't have permission to access /.

Rob



Re: [Qemu-devel] [PATCH 3/3] vhost: roll our own cpu map variant

2011-03-29 Thread Stefan Hajnoczi
On Mon, Mar 28, 2011 at 10:14 PM, Michael S. Tsirkin m...@redhat.com wrote:
 vhost used cpu_physical_memory_map to get the
 virtual address for the ring, however,
 this will exit on an illegal RAM address.
 Since the addresses are guest-controlled, we
 shouldn't do that.

 Switch to our own variant that uses the vhost
 tables and returns an error instead of exiting.

We should make all of QEMU more robust instead of just vhost.  Perhaps
introduce cpu_physical_memory_map_nofail(...) that aborts like the
current cpu_physical_memory_map() implementation and then make non-hw/
users call that one.  hw/ users should check for failure.

Stefan



[Qemu-devel] lan9118 network performance issue

2011-03-29 Thread Sid Kapoor
Hi,

I am using ARM realview cortex a9 board with qemu-0.14.0
It uses lan9118 network interface. I am connecting to the outside network by
creating a bridge on my host's eth0 interface.
I am facing some network glitch while transferring a large file. If I
transfer a small file between my guest and host of size around 20-30 MB, the
transfer is smooth with transfer speed comparable to the host machine. But
if I try transferring a large file, of around 200 MB, the transfer of around
30-40 MB is smooth, after that the network stalls for a few seconds, around
15-20 seconds, then resumes with the file transfer.
I dig into the code a bit, in hw/lan9118.c .  In this lan9118_writel() is
called for pushing packets into the tx_fifo for transferring the file.If the
'offset' is between 0x20 and 0x40, tx_fifo_push() is getting called. In this
case, the file transfer is smooth. The reason for stalling of network
is that is the offset is outside this range and tx_fifo_push() is not
getting called. While the network is stalled, the offset in lan9118_writel()
function is 0x58 and 0x5c to be precise.
What is the reason of network getting stalled for these offset values? What
is the significance of these offset for lan9118 interface?

Thanks,
Sid


[Qemu-devel] Re: [PATCH V2] hw/xen_disk: ioreq not finished on error

2011-03-29 Thread Kevin Wolf
Am 29.03.2011 12:48, schrieb Stefano Stabellini:
 On Tue, 29 Mar 2011, Feiran Zheng wrote:
 Bug fix: routines 'ioreq_runio_qemu_sync' and 'ioreq_runio_qemu_aio'
 won't call 'ioreq_unmap' or 'ioreq_finish' on errors, leaving ioreq in
 the blkdev-inflight list and a leak.

 
 Acked-by: Stefano Stabellini stefano.stabell...@eu.citrix.com

Thanks, applied to the block branch.

Kevin



Re: [Qemu-devel] [PATCH 0/2] avoid races on exec migration

2011-03-29 Thread Markus Armbruster
Paolo Bonzini pbonz...@redhat.com writes:

 QEMU has a sigchld handler that reaps any child process.  -smb is the
 only user of it and, in fact, QEMU inherited it from slirp.  However,
 this handler causes 'exec' based migration to randomly return 'status:
 failed' in the monitor.  This happens when the signal handler for SIGCHLD
 is ran before the pclose() of exec migration.

Signal handler uses undirected waitpid(), which can steal the zombie
from pclose() (race condition).  pclose() doesn't expect that, and
fails.

 The return status of fclose() is passed back as return status of
 qemu_fclose().  If qemu_fclose() fails, then the exec_close() in
 migration-exec.c returns a error code. This causes migrate_fd_cleanup()
 to return an error, and thus finally we see why 'status: failed' occurs:

 if (migrate_fd_cleanup(s)  0) {
 if (old_vm_running) {
 vm_start();
 }
 state = MIG_STATE_ERROR;
 }

 To avoid this, register the pids in a list and, on SIGCHLD, set up a
 bottom-half that would go through the pids and reap them.

Signal handler now waitpid()s only for registered children, so it can't
steal zombies anymore.

 Since I'm at it, I'm moving iohandler stuff out of vl.c.  The new
 file isn't a perfect place to add the child watcher, but it's arguably
 better than vl.c.

Pretty much anything's better than vl.c.

You silently drop unused IOHandlerRecord member ufd.  Dropping junk
good, silence not so good.

Not sure iohandler.c is the best home for qemu_add_child_watch() 
friends, but at least it's not vl.c ;)

 This should be applied to both master and stable.

Acked-by: Markus Armbruster arm...@redhat.com



Re: [Qemu-devel] qemu-git web viewer?

2011-03-29 Thread Frédéric Grelot
See above mail, sent by Anthony yesterday :


 We've been having problems on qemu.org all day.  Initially, it was
 due
 to a combination of a small DoS attack (not uncommon unfortunately).

 Later, the issue was observed when a crawler that was ignoring
 robots.txt started indexing git.qemu.org.  We use cgit because of the
 fact that it does aggressive caching but it also seems to frequently
 SEGV leaving stale lock files.  This is causing all pages to be
 dynamically generated which is an extremely slow path with cgit.

 For now, I've disabled cgit until I can try a newer version.  This
 only
 affects the web interface.  Pulling and pushing via the git:// or
 ssh://
 will continue to work.

 Regards,

 Anthony Liguori


--
frede...@grelot.net
Tél : 09 54 76 14 26 / 06 82 23 46 17
while(!asleep()) sheep++

- Mail original -
 Is there a web viewer for the git repository?

 The download page links to http://git.qemu.org/qemu.git but that's
 404,
 and http://git.qemu.org says I don't have permission to access /.

 Rob





[Qemu-devel] [PATCH 0/3] sheepdog: fix aio related issues

2011-03-29 Thread MORITA Kazutaka
This patchset fixes the Sheepodg AIO problems pointed out in:
  http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg02495.html
  http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg02474.html

Thanks,

Kazutaka


MORITA Kazutaka (3):
  sheepdog: make send/recv operations non-blocking
  sheepdog: allow cancellation of I/Os which are not processed yet
  sheepdog: avoid accessing a buffer of the canceled I/O request

 block/sheepdog.c |  462 +++---
 1 files changed, 334 insertions(+), 128 deletions(-)




[Qemu-devel] [PATCH 3/3] sheepdog: avoid accessing a buffer of the canceled I/O request

2011-03-29 Thread MORITA Kazutaka
We cannot access the buffer of the canceled I/O request because its
AIOCB callback is already called and the buffer is not valid.

Signed-off-by: MORITA Kazutaka morita.kazut...@lab.ntt.co.jp
---
 block/sheepdog.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index ed98701..6f60721 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -79,6 +79,7 @@
 #define SD_DATA_OBJ_SIZE (UINT64_C(1)  22)
 #define SD_MAX_VDI_SIZE (SD_DATA_OBJ_SIZE * MAX_DATA_OBJS)
 #define SECTOR_SIZE 512
+#define BUF_SIZE 4096
 
 #define SD_INODE_SIZE (sizeof(SheepdogInode))
 #define CURRENT_VDI_ID 0
@@ -900,8 +901,15 @@ static void aio_read_response(void *opaque)
 }
 conn_state = C_IO_DATA;
 case C_IO_DATA:
-ret = do_readv(fd, acb-qiov-iov, aio_req-data_len - done,
-   aio_req-iov_offset + done);
+if (acb-canceled) {
+char tmp_buf[BUF_SIZE];
+int len = MIN(aio_req-data_len - done, sizeof(tmp_buf));
+
+ret = do_read(fd, tmp_buf, len, 0);
+} else {
+ret = do_readv(fd, acb-qiov-iov, aio_req-data_len - done,
+   aio_req-iov_offset + done);
+}
 if (ret  0) {
 error_report(failed to get the data, %s\n, strerror(errno));
 conn_state = C_IO_CLOSED;
-- 
1.5.6.5




[Qemu-devel] [PATCH 2/3] sheepdog: allow cancellation of I/Os which are not processed yet

2011-03-29 Thread MORITA Kazutaka
We can cancel I/O requests safely if they are not sent to the servers.

Signed-off-by: MORITA Kazutaka morita.kazut...@lab.ntt.co.jp
---
 block/sheepdog.c |   37 +
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index cedf806..ed98701 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -421,6 +421,43 @@ static void sd_finish_aiocb(SheepdogAIOCB *acb)
 static void sd_aio_cancel(BlockDriverAIOCB *blockacb)
 {
 SheepdogAIOCB *acb = (SheepdogAIOCB *)blockacb;
+BDRVSheepdogState *s = blockacb-bs-opaque;
+AIOReq *areq, *next, *oldest_send_req = NULL;
+
+if (acb-bh) {
+/*
+ * sd_readv_writev_bh_cb() is not called yet, so we can
+ * release this safely
+ */
+qemu_bh_delete(acb-bh);
+acb-bh = NULL;
+qemu_aio_release(acb);
+return;
+}
+
+QLIST_FOREACH(areq, s-outstanding_aio_head, outstanding_aio_siblings) {
+if (areq-state == AIO_SEND_OBJREQ) {
+oldest_send_req = areq;
+}
+}
+
+QLIST_FOREACH_SAFE(areq, s-outstanding_aio_head,
+   outstanding_aio_siblings, next) {
+if (areq-state == AIO_RECV_OBJREQ) {
+continue;
+}
+if (areq-state == AIO_SEND_OBJREQ  areq == oldest_send_req) {
+/* the oldest AIO_SEND_OBJREQ request could be being sent */
+continue;
+}
+free_aio_req(s, areq);
+}
+
+if (QLIST_EMPTY(acb-aioreq_head)) {
+/* there is no outstanding request */
+qemu_aio_release(acb);
+return;
+}
 
 /*
  * Sheepdog cannot cancel the requests which are already sent to
-- 
1.5.6.5




[Qemu-devel] [PATCH 1/3] sheepdog: make send/recv operations non-blocking

2011-03-29 Thread MORITA Kazutaka
This patch avoids retrying send/recv in AIO path when the sheepdog
connection is not ready for the operation.

Signed-off-by: MORITA Kazutaka morita.kazut...@lab.ntt.co.jp
---
 block/sheepdog.c |  417 +-
 1 files changed, 289 insertions(+), 128 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index a54e0de..cedf806 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -242,6 +242,19 @@ static inline int is_snapshot(struct SheepdogInode *inode)
 
 typedef struct SheepdogAIOCB SheepdogAIOCB;
 
+enum ConnectionState {
+C_IO_HEADER,
+C_IO_DATA,
+C_IO_END,
+C_IO_CLOSED,
+};
+
+enum AIOReqState {
+AIO_PENDING,/* not ready for sending this request */
+AIO_SEND_OBJREQ,/* send this request */
+AIO_RECV_OBJREQ,/* receive a result of this request */
+};
+
 typedef struct AIOReq {
 SheepdogAIOCB *aiocb;
 unsigned int iov_offset;
@@ -253,6 +266,9 @@ typedef struct AIOReq {
 uint8_t flags;
 uint32_t id;
 
+enum AIOReqState state;
+struct SheepdogObjReq hdr;
+
 QLIST_ENTRY(AIOReq) outstanding_aio_siblings;
 QLIST_ENTRY(AIOReq) aioreq_siblings;
 } AIOReq;
@@ -348,12 +364,14 @@ static const char * sd_strerror(int err)
  * 1. In the sd_aio_readv/writev, read/write requests are added to the
  *QEMU Bottom Halves.
  *
- * 2. In sd_readv_writev_bh_cb, the callbacks of BHs, we send the I/O
- *requests to the server and link the requests to the
- *outstanding_list in the BDRVSheepdogState.  we exits the
- *function without waiting for receiving the response.
+ * 2. In sd_readv_writev_bh_cb, the callbacks of BHs, we set up the
+ *I/O requests to the server and link the requests to the
+ *outstanding_list in the BDRVSheepdogState.
+ *
+ * 3. We send the request in aio_send_request, the fd handler to the
+ *sheepdog connection.
  *
- * 3. We receive the response in aio_read_response, the fd handler to
+ * 4. We receive the response in aio_read_response, the fd handler to
  *the sheepdog connection.  If metadata update is needed, we send
  *the write request to the vdi object in sd_write_done, the write
  *completion function.  The AIOCB callback is not called until all
@@ -377,8 +395,6 @@ static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, 
SheepdogAIOCB *acb,
 aio_req-flags = flags;
 aio_req-id = s-aioreq_seq_num++;
 
-QLIST_INSERT_HEAD(s-outstanding_aio_head, aio_req,
-  outstanding_aio_siblings);
 QLIST_INSERT_HEAD(acb-aioreq_head, aio_req, aioreq_siblings);
 
 return aio_req;
@@ -640,20 +656,17 @@ static int do_readv_writev(int sockfd, struct iovec *iov, 
int len,
 again:
 ret = do_send_recv(sockfd, iov, len, iov_offset, write);
 if (ret  0) {
-if (errno == EINTR || errno == EAGAIN) {
+if (errno == EINTR) {
 goto again;
 }
+if (errno == EAGAIN) {
+return 0;
+}
 error_report(failed to recv a rsp, %s\n, strerror(errno));
-return 1;
-}
-
-iov_offset += ret;
-len -= ret;
-if (len) {
-goto again;
+return -errno;
 }
 
-return 0;
+return ret;
 }
 
 static int do_readv(int sockfd, struct iovec *iov, int len, int iov_offset)
@@ -666,30 +679,30 @@ static int do_writev(int sockfd, struct iovec *iov, int 
len, int iov_offset)
 return do_readv_writev(sockfd, iov, len, iov_offset, 1);
 }
 
-static int do_read_write(int sockfd, void *buf, int len, int write)
+static int do_read_write(int sockfd, void *buf, int len, int skip, int write)
 {
 struct iovec iov;
 
 iov.iov_base = buf;
-iov.iov_len = len;
+iov.iov_len = len + skip;
 
-return do_readv_writev(sockfd, iov, len, 0, write);
+return do_readv_writev(sockfd, iov, len, skip, write);
 }
 
-static int do_read(int sockfd, void *buf, int len)
+static int do_read(int sockfd, void *buf, int len, int skip)
 {
-return do_read_write(sockfd, buf, len, 0);
+return do_read_write(sockfd, buf, len, skip, 0);
 }
 
-static int do_write(int sockfd, void *buf, int len)
+static int do_write(int sockfd, void *buf, int len, int skip)
 {
-return do_read_write(sockfd, buf, len, 1);
+return do_read_write(sockfd, buf, len, skip, 1);
 }
 
 static int send_req(int sockfd, SheepdogReq *hdr, void *data,
 unsigned int *wlen)
 {
-int ret;
+int ret, done = 0;
 struct iovec iov[2];
 
 iov[0].iov_base = hdr;
@@ -700,19 +713,23 @@ static int send_req(int sockfd, SheepdogReq *hdr, void 
*data,
 iov[1].iov_len = *wlen;
 }
 
-ret = do_writev(sockfd, iov, sizeof(*hdr) + *wlen, 0);
-if (ret) {
-error_report(failed to send a req, %s\n, strerror(errno));
-ret = -1;
+while (done  sizeof(*hdr) + *wlen) {
+ret = do_writev(sockfd, iov, sizeof(*hdr) + *wlen - done, done);
+if (ret  0) {
+error_report(failed to send a req, 

[Qemu-devel] Re: [PATCH 0/2] avoid races on exec migration

2011-03-29 Thread Paolo Bonzini

On 03/29/2011 01:52 PM, Markus Armbruster wrote:

To avoid this, register the pids in a list and, on SIGCHLD, set up a
bottom-half that would go through the pids and reap them.


Signal handler now waitpid()s only for registered children, so it can't
steal zombies anymore.


Exactly.


Since I'm at it, I'm moving iohandler stuff out of vl.c.  The new
file isn't a perfect place to add the child watcher, but it's arguably
better than vl.c.


Pretty much anything's better than vl.c.

You silently drop unused IOHandlerRecord member ufd.  Dropping junk
good, silence not so good.


1/2 had a pretty terse commit message overall.

Paolo



[Qemu-devel] Re: [PATCH 2/3] Redirect cpu_interrupt to callback handler

2011-03-29 Thread Marcelo Tosatti
On Fri, Mar 18, 2011 at 01:19:15PM +0100, Jan Kiszka wrote:
 From: Jan Kiszka jan.kis...@siemens.com
 
 This allows to override the interrupt handling of QEMU in system mode.
 KVM will make use of it to set a specialized handler.
 
 Signed-off-by: Jan Kiszka jan.kis...@siemens.com
 ---
  cpu-all.h |   14 +-
  exec.c|4 +++-
  2 files changed, 16 insertions(+), 2 deletions(-)
 
 diff --git a/cpu-all.h b/cpu-all.h
 index 4f4631d..5835cfa 100644
 --- a/cpu-all.h
 +++ b/cpu-all.h
 @@ -790,7 +790,19 @@ extern CPUState *cpu_single_env;
  #define CPU_INTERRUPT_SIPI   0x800 /* SIPI pending. */
  #define CPU_INTERRUPT_MCE0x1000 /* (x86 only) MCE pending. */
  
 -void cpu_interrupt(CPUState *s, int mask);
 +#ifndef CONFIG_USER_ONLY
 +typedef void (*CPUInterruptHandler)(CPUState *, int);
 +
 +extern CPUInterruptHandler cpu_interrupt_handler;
 +
 +static inline void cpu_interrupt(CPUState *s, int mask)
 +{
 +cpu_interrupt_handler(s, mask);
 +}
 +#else /* USER_ONLY */
 +void cpu_interrupt(CPUState *env, int mask);
 +#endif /* USER_ONLY */
 +
  void cpu_reset_interrupt(CPUState *env, int mask);
  
  void cpu_exit(CPUState *s);
 diff --git a/exec.c b/exec.c
 index 4721f04..0c80f84 100644
 --- a/exec.c
 +++ b/exec.c
 @@ -1632,7 +1632,7 @@ static void cpu_unlink_tb(CPUState *env)
  
  #ifndef CONFIG_USER_ONLY
  /* mask must never be zero, except for A20 change call */
 -void cpu_interrupt(CPUState *env, int mask)
 +static void tcg_handle_interrupt(CPUState *env, int mask)
  {
  int old_mask;
  
 @@ -1659,6 +1659,8 @@ void cpu_interrupt(CPUState *env, int mask)
  }
  }
  
 +CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;
 +
  #else /* CONFIG_USER_ONLY */
  
  void cpu_interrupt(CPUState *env, int mask)
 -- 
 1.7.1

Perhaps a function would be a better interface, but can be changed
later.





[Qemu-devel] KVM call agenda for Mars 29th

2011-03-29 Thread Juan Quintela

Please, send in any agenda items you are interested in covering.

Later, Juan.



Re: [Qemu-devel] qemu-git web viewer?

2011-03-29 Thread Anthony Liguori

On 03/29/2011 06:58 AM, Frédéric Grelot wrote:

See above mail, sent by Anthony yesterday :


My plan is to upgrade cgit later today FWIW.  If anyone has experience 
with other git front ends, I'd appreciate hearing about it.  Since 
qemu.org has pretty high traffic, I wanted something that cached 
aggressively.


Other than this current issue, I've had pretty good experiences with 
cgit so far.


Regards,

Anthony Liguori




We've been having problems on qemu.org all day.  Initially, it was
due
to a combination of a small DoS attack (not uncommon unfortunately).

Later, the issue was observed when a crawler that was ignoring
robots.txt started indexing git.qemu.org.  We use cgit because of the
fact that it does aggressive caching but it also seems to frequently
SEGV leaving stale lock files.  This is causing all pages to be
dynamically generated which is an extremely slow path with cgit.

For now, I've disabled cgit until I can try a newer version.  This
only
affects the web interface.  Pulling and pushing via the git:// or
ssh://
will continue to work.

Regards,

Anthony Liguori







[Qemu-devel] [PATCH 01/19] Only build ivshmem when CONFIG_PCI CONFIG_KVM

2011-03-29 Thread Alexander Graf
The ivshmem depends on PCI and KVM, not only KVM. Reflect this
in the Makefile, so we don't get build errors on s390x.

Signed-off-by: Alexander Graf ag...@suse.de
CC: Cam Macdonell c...@cs.ualberta.ca
CC: Juan Quintela quint...@redhat.com
---
 Makefile.target |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 62b102a..663a101 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -209,7 +209,13 @@ QEMU_CFLAGS += $(VNC_PNG_CFLAGS)
 obj-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o
 
 # Inter-VM PCI shared memory
-obj-$(CONFIG_KVM) += ivshmem.o
+CONFIG_IVSHMEM =
+ifeq ($(CONFIG_KVM), y)
+  ifeq ($(CONFIG_PCI), y)
+CONFIG_IVSHMEM = y
+  endif
+endif
+obj-$(CONFIG_IVSHMEM) += ivshmem.o
 
 # Hardware support
 obj-i386-y += vga.o
-- 
1.6.0.2




[Qemu-devel] [PATCH 05/19] s390x: Enable disassembler for s390x

2011-03-29 Thread Alexander Graf
From: Ulrich Hecht u...@suse.de

This patch enables the instruction disassembler when using an
S390x target.

Signed-off-by: Ulrich Hecht u...@suse.de
---
 disas.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/disas.c b/disas.c
index c76f36f..17b4ce4 100644
--- a/disas.c
+++ b/disas.c
@@ -215,6 +215,9 @@ void target_disas(FILE *out, target_ulong code, 
target_ulong size, int flags)
 disasm_info.mach = bfd_mach_cris_v32;
 print_insn = print_insn_crisv32;
 }
+#elif defined(TARGET_S390X)
+disasm_info.mach = bfd_mach_s390_64;
+print_insn = print_insn_s390;
 #elif defined(TARGET_MICROBLAZE)
 disasm_info.mach = bfd_arch_microblaze;
 print_insn = print_insn_microblaze;
@@ -414,6 +417,9 @@ void monitor_disas(Monitor *mon, CPUState *env,
 #elif defined(TARGET_SH4)
 disasm_info.mach = bfd_mach_sh4;
 print_insn = print_insn_sh;
+#elif defined(TARGET_S390X)
+disasm_info.mach = bfd_mach_s390_64;
+print_insn = print_insn_s390;
 #else
 monitor_printf(mon, 0x TARGET_FMT_lx
: Asm output not supported on this arch\n, pc);
-- 
1.6.0.2




[Qemu-devel] [PATCH 11/19] s390x: Dispatch interrupts to KVM or the real CPU

2011-03-29 Thread Alexander Graf
The KVM interrupt injection path is non-generic for now. So we need to push
knowledge of how to inject a device interrupt using KVM into the actual device
code.

Signed-off-by: Alexander Graf ag...@suse.de
---
 hw/s390-virtio-bus.c |   10 --
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 58af164..6a32939 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -43,6 +43,8 @@
 do { } while (0)
 #endif
 
+#define VIRTIO_EXT_CODE   0x2603
+
 struct BusInfo s390_virtio_bus_info = {
 .name   = s390-virtio,
 .size   = sizeof(VirtIOS390Bus),
@@ -304,9 +306,13 @@ static void virtio_s390_notify(void *opaque, uint16_t 
vector)
 {
 VirtIOS390Device *dev = (VirtIOS390Device*)opaque;
 uint64_t token = s390_virtio_device_vq_token(dev, vector);
+CPUState *env = s390_cpu_addr2state(0);
 
-/* XXX kvm dependency! */
-kvm_s390_virtio_irq(s390_cpu_addr2state(0), 0, token);
+if (kvm_enabled()) {
+kvm_s390_virtio_irq(env, 0, token);
+} else {
+cpu_inject_ext(env, VIRTIO_EXT_CODE, 0, token);
+}
 }
 
 static unsigned virtio_s390_get_features(void *opaque)
-- 
1.6.0.2




[Qemu-devel] [PATCH 02/19] virtio: use generic name when possible

2011-03-29 Thread Alexander Graf
We have two different virtio buses: pci and s390. The abstraction path
taken in qemu is to have generic aliases for each device type in the
architecture specific qdev devices.

So let's make use of these aliases whenever we can and define them
whenever we can.

Signed-off-by: Alexander Graf ag...@suse.de
---
 blockdev.c   |2 +-
 hw/s390-virtio-bus.c |2 ++
 hw/virtio-pci.c  |3 +++
 vl.c |6 +++---
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index ecf2252..bbe92fe 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -503,7 +503,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
 case IF_VIRTIO:
 /* add virtio block device */
 opts = qemu_opts_create(qemu_find_opts(device), NULL, 0);
-qemu_opt_set(opts, driver, virtio-blk-pci);
+qemu_opt_set(opts, driver, virtio-blk);
 qemu_opt_set(opts, drive, dinfo-id);
 if (devaddr)
 qemu_opt_set(opts, addr, devaddr);
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 784dc01..d44eff2 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -325,6 +325,7 @@ static const VirtIOBindings virtio_s390_bindings = {
 static VirtIOS390DeviceInfo s390_virtio_net = {
 .init = s390_virtio_net_init,
 .qdev.name = virtio-net-s390,
+.qdev.alias = virtio-net,
 .qdev.size = sizeof(VirtIOS390Device),
 .qdev.props = (Property[]) {
 DEFINE_NIC_PROPERTIES(VirtIOS390Device, nic),
@@ -340,6 +341,7 @@ static VirtIOS390DeviceInfo s390_virtio_net = {
 static VirtIOS390DeviceInfo s390_virtio_blk = {
 .init = s390_virtio_blk_init,
 .qdev.name = virtio-blk-s390,
+.qdev.alias = virtio-blk,
 .qdev.size = sizeof(VirtIOS390Device),
 .qdev.props = (Property[]) {
 DEFINE_BLOCK_PROPERTIES(VirtIOS390Device, block),
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index df10703..555f23f 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -873,6 +873,7 @@ static PCIDeviceInfo virtio_info[] = {
 .qdev.reset = virtio_pci_reset,
 },{
 .qdev.name  = virtio-net-pci,
+.qdev.alias = virtio-net,
 .qdev.size  = sizeof(VirtIOPCIProxy),
 .init   = virtio_net_init_pci,
 .exit   = virtio_net_exit_pci,
@@ -911,6 +912,7 @@ static PCIDeviceInfo virtio_info[] = {
 .qdev.reset = virtio_pci_reset,
 },{
 .qdev.name = virtio-balloon-pci,
+.qdev.alias = virtio-balloon,
 .qdev.size = sizeof(VirtIOPCIProxy),
 .init  = virtio_balloon_init_pci,
 .exit  = virtio_exit_pci,
@@ -922,6 +924,7 @@ static PCIDeviceInfo virtio_info[] = {
 },{
 #ifdef CONFIG_VIRTFS
 .qdev.name = virtio-9p-pci,
+.qdev.alias = virtio-9p,
 .qdev.size = sizeof(VirtIOPCIProxy),
 .init  = virtio_9p_init_pci,
 .qdev.props = (Property[]) {
diff --git a/vl.c b/vl.c
index 192a240..462c2e3 100644
--- a/vl.c
+++ b/vl.c
@@ -1687,7 +1687,7 @@ static int balloon_parse(const char *arg)
 /* create empty opts */
 opts = qemu_opts_create(qemu_find_opts(device), NULL, 0);
 }
-qemu_opt_set(opts, driver, virtio-balloon-pci);
+qemu_opt_set(opts, driver, virtio-balloon);
 return 0;
 }
 
@@ -2573,12 +2573,12 @@ int main(int argc, char **argv, char **envp)
  qemu_opt_get(opts, path),
  qemu_opt_get(opts, security_model));
 
-len = strlen(virtio-9p-pci,fsdev=,mount_tag=);
+len = strlen(virtio-9p,fsdev=,mount_tag=);
 len += 2*strlen(qemu_opt_get(opts, mount_tag));
 arg_9p = qemu_malloc((len + 1) * sizeof(*arg_9p));
 
 snprintf(arg_9p, (len + 1) * sizeof(*arg_9p),
- virtio-9p-pci,fsdev=%s,mount_tag=%s,
+ virtio-9p,fsdev=%s,mount_tag=%s,
  qemu_opt_get(opts, mount_tag),
  qemu_opt_get(opts, mount_tag));
 
-- 
1.6.0.2




[Qemu-devel] [PATCH 06/19] s390x: Enable nptl for s390x

2011-03-29 Thread Alexander Graf
From: Ulrich Hecht u...@suse.de

S390x user emulation can do nptl. Reflect this in the configure script.

Signed-off-by: Ulrich Hecht u...@suse.de
---
 configure |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 5a5827f..978fd1f 100755
--- a/configure
+++ b/configure
@@ -3100,6 +3100,7 @@ case $target_arch2 in
 target_phys_bits=64
   ;;
   s390x)
+target_nptl=yes
 target_phys_bits=64
   ;;
   *)
-- 
1.6.0.2




[Qemu-devel] [PATCH 17/19] s390x: Adjust internal kvm code

2011-03-29 Thread Alexander Graf
We're now finally emulating an s390x CPU, so we can move quite some logic
from the kvm code out into generic CPU code.

This patch does this and adjusts the interfaces according to what the code
around now expects to be able to call.

Signed-off-by: Alexander Graf ag...@suse.de
---
 target-s390x/kvm.c |   60 ---
 1 files changed, 14 insertions(+), 46 deletions(-)

diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index ae7dc56..f464367 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -49,13 +49,6 @@
 #define DIAG_KVM_HYPERCALL  0x500
 #define DIAG_KVM_BREAKPOINT 0x501
 
-#define SCP_LENGTH  0x00
-#define SCP_FUNCTION_CODE   0x02
-#define SCP_CONTROL_MASK0x03
-#define SCP_RESPONSE_CODE   0x06
-#define SCP_MEM_CODE0x08
-#define SCP_INCREMENT   0x0a
-
 #define ICPT_INSTRUCTION0x04
 #define ICPT_WAITPSW0x1c
 #define ICPT_SOFT_INTERCEPT 0x24
@@ -182,8 +175,8 @@ int kvm_arch_process_async_events(CPUState *env)
 return 0;
 }
 
-static void kvm_s390_interrupt_internal(CPUState *env, int type, uint32_t parm,
-uint64_t parm64, int vm)
+void kvm_s390_interrupt_internal(CPUState *env, int type, uint32_t parm,
+ uint64_t parm64, int vm)
 {
 struct kvm_s390_interrupt kvmint;
 int r;
@@ -218,7 +211,7 @@ void kvm_s390_virtio_irq(CPUState *env, int config_change, 
uint64_t token)
 token, 1);
 }
 
-static void kvm_s390_interrupt(CPUState *env, int type, uint32_t code)
+void kvm_s390_interrupt(CPUState *env, int type, uint32_t code)
 {
 kvm_s390_interrupt_internal(env, type, code, 0, 0);
 }
@@ -228,16 +221,16 @@ static void enter_pgmcheck(CPUState *env, uint16_t code)
 kvm_s390_interrupt(env, KVM_S390_PROGRAM_INT, code);
 }
 
-static void setcc(CPUState *env, uint64_t cc)
+static inline void setcc(CPUState *env, uint64_t cc)
 {
-env-kvm_run-psw_mask = ~(3ul  44);
+env-kvm_run-psw_mask = ~(3ull  44);
 env-kvm_run-psw_mask |= (cc  3)  44;
 
 env-psw.mask = ~(3ul  44);
 env-psw.mask |= (cc  3)  44;
 }
 
-static int sclp_service_call(CPUState *env, struct kvm_run *run, uint16_t 
ipbh0)
+static int kvm_sclp_service_call(CPUState *env, struct kvm_run *run, uint16_t 
ipbh0)
 {
 uint32_t sccb;
 uint64_t code;
@@ -247,35 +240,11 @@ static int sclp_service_call(CPUState *env, struct 
kvm_run *run, uint16_t ipbh0)
 sccb = env-regs[ipbh0  0xf];
 code = env-regs[(ipbh0  0xf0)  4];
 
-dprintf(sclp(0x%x, 0x%lx)\n, sccb, code);
-
-if (sccb  ~0x7ff8ul) {
-fprintf(stderr, KVM: invalid sccb address 0x%x\n, sccb);
-r = -1;
-goto out;
-}
-
-switch(code) {
-case SCLP_CMDW_READ_SCP_INFO:
-case SCLP_CMDW_READ_SCP_INFO_FORCED:
-stw_phys(sccb + SCP_MEM_CODE, ram_size  20);
-stb_phys(sccb + SCP_INCREMENT, 1);
-stw_phys(sccb + SCP_RESPONSE_CODE, 0x10);
-setcc(env, 0);
-
-kvm_s390_interrupt_internal(env, KVM_S390_INT_SERVICE,
-sccb  ~3, 0, 1);
-break;
-default:
-dprintf(KVM: invalid sclp call 0x%x / 0x%lx\n, sccb, code);
-r = -1;
-break;
-}
-
-out:
-if (r  0) {
+r = sclp_service_call(env, sccb, code);
+if (r) {
 setcc(env, 3);
 }
+
 return 0;
 }
 
@@ -287,7 +256,7 @@ static int handle_priv(CPUState *env, struct kvm_run *run, 
uint8_t ipa1)
 dprintf(KVM: PRIV: %d\n, ipa1);
 switch (ipa1) {
 case PRIV_SCLP_CALL:
-r = sclp_service_call(env, run, ipbh0);
+r = kvm_sclp_service_call(env, run, ipbh0);
 break;
 default:
 dprintf(KVM: unknown PRIV: 0x%x\n, ipa1);
@@ -300,12 +269,10 @@ static int handle_priv(CPUState *env, struct kvm_run 
*run, uint8_t ipa1)
 
 static int handle_hypercall(CPUState *env, struct kvm_run *run)
 {
-int r;
-
 cpu_synchronize_state(env);
-r = s390_virtio_hypercall(env);
+env-regs[2] = s390_virtio_hypercall(env, env-regs[2], env-regs[1]);
 
-return r;
+return 0;
 }
 
 static int handle_diag(CPUState *env, struct kvm_run *run, int ipb_code)
@@ -450,7 +417,8 @@ static int handle_intercept(CPUState *env)
 int icpt_code = run-s390_sieic.icptcode;
 int r = 0;
 
-dprintf(intercept: 0x%x (at 0x%lx)\n, icpt_code, env-kvm_run-psw_addr);
+dprintf(intercept: 0x%x (at 0x%lx)\n, icpt_code,
+(long)env-kvm_run-psw_addr);
 switch (icpt_code) {
 case ICPT_INSTRUCTION:
 r = handle_instruction(env, run);
-- 
1.6.0.2




[Qemu-devel] [PATCH 13/19] s390x: virtio machine storage keys

2011-03-29 Thread Alexander Graf
For emulation (and migration) we need to know about the guest's storage keys.
These are separate from actual RAM contents, so we need to allocate them in
parallel to RAM.

While touching the file, this patch also adjusts the hypercall function
to a new syntax that aligns better with tcg emulated code.

Signed-off-by: Alexander Graf ag...@suse.de
---
 hw/s390-virtio.c |   21 +
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index 850422f..be2c80c 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -82,13 +82,12 @@ CPUState *s390_cpu_addr2state(uint16_t cpu_addr)
 return ipi_states[cpu_addr];
 }
 
-int s390_virtio_hypercall(CPUState *env)
+int s390_virtio_hypercall(CPUState *env, uint64_t mem, uint64_t hypercall)
 {
 int r = 0, i;
-target_ulong mem = env-regs[2];
 
-dprintf(KVM hypercall: %ld\n, env-regs[1]);
-switch (env-regs[1]) {
+dprintf(KVM hypercall: %ld\n, hypercall);
+switch (hypercall) {
 case KVM_S390_VIRTIO_NOTIFY:
 if (mem  ram_size) {
 VirtIOS390Device *dev = s390_virtio_bus_find_vring(s390_bus,
@@ -128,8 +127,7 @@ int s390_virtio_hypercall(CPUState *env)
 break;
 }
 
-env-regs[2] = r;
-return 0;
+return r;
 }
 
 /* PC hardware initialisation */
@@ -145,14 +143,9 @@ static void s390_init(ram_addr_t ram_size,
 ram_addr_t kernel_size = 0;
 ram_addr_t initrd_offset;
 ram_addr_t initrd_size = 0;
+uint8_t *storage_keys;
 int i;
 
-/* XXX we only work on KVM for now */
-
-if (!kvm_enabled()) {
-fprintf(stderr, The S390 target only works with KVM enabled\n);
-exit(1);
-}
 
 /* get a BUS */
 s390_bus = s390_virtio_bus_init(ram_size);
@@ -161,6 +154,9 @@ static void s390_init(ram_addr_t ram_size,
 ram_addr = qemu_ram_alloc(NULL, s390.ram, ram_size);
 cpu_register_physical_memory(0, ram_size, ram_addr);
 
+/* allocate storage keys */
+storage_keys = qemu_mallocz(ram_size / TARGET_PAGE_SIZE);
+
 /* init CPUs */
 if (cpu_model == NULL) {
 cpu_model = host;
@@ -178,6 +174,7 @@ static void s390_init(ram_addr_t ram_size,
 ipi_states[i] = tmp_env;
 tmp_env-halted = 1;
 tmp_env-exception_index = EXCP_HLT;
+tmp_env-storage_keys = storage_keys;
 }
 
 env-halted = 0;
-- 
1.6.0.2




[Qemu-devel] [PATCH 04/19] s390x: fix s390-virtio-serial

2011-03-29 Thread Alexander Graf
Commit 6b331efb733a0f913ddc0b7762a1307dec304061 broke the s390 proxy version
of virtio-serial by only taking its PCI brother into account.

So let's adjust s390-virtio-serial the same way as its PCI counterpart, making
it compile and work again.

Signed-off-by: Alexander Graf ag...@suse.de
CC: Amit Shah amit.s...@redhat.com
---
 hw/s390-virtio-bus.c |6 +++---
 hw/s390-virtio-bus.h |4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index d44eff2..58af164 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -139,7 +139,7 @@ static int s390_virtio_serial_init(VirtIOS390Device *dev)
 
 bus = DO_UPCAST(VirtIOS390Bus, bus, dev-qdev.parent_bus);
 
-vdev = virtio_serial_init((DeviceState *)dev, dev-max_virtserial_ports);
+vdev = virtio_serial_init((DeviceState *)dev, dev-serial);
 if (!vdev) {
 return -1;
 }
@@ -355,8 +355,8 @@ static VirtIOS390DeviceInfo s390_virtio_serial = {
 .qdev.alias = virtio-serial,
 .qdev.size = sizeof(VirtIOS390Device),
 .qdev.props = (Property[]) {
-DEFINE_PROP_UINT32(max_ports, VirtIOS390Device, max_virtserial_ports,
-   31),
+DEFINE_PROP_UINT32(max_ports, VirtIOS390Device,
+   serial.max_virtserial_ports, 31),
 DEFINE_PROP_END_OF_LIST(),
 },
 };
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index 33379a3..edf6d04 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -18,6 +18,7 @@
  */
 
 #include virtio-net.h
+#include virtio-serial.h
 
 #define VIRTIO_DEV_OFFS_TYPE   0   /* 8 bits */
 #define VIRTIO_DEV_OFFS_NUM_VQ 1   /* 8 bits */
@@ -43,8 +44,7 @@ typedef struct VirtIOS390Device {
 BlockConf block;
 NICConf nic;
 uint32_t host_features;
-/* Max. number of ports we can have for a the virtio-serial device */
-uint32_t max_virtserial_ports;
+virtio_serial_conf serial;
 virtio_net_conf net;
 } VirtIOS390Device;
 
-- 
1.6.0.2




[Qemu-devel] [PATCH 03/19] s390x: fix KVM target

2011-03-29 Thread Alexander Graf
During Jan's rework of the generic KVM layer, he added some more error checks
and actually aborted if something went wrong. Unfortunately, one of the s390
internal error codes slipped through, aborting the VM without needing to.

This patch fixes booting of S390x virtual machines in KVM.

Signed-off-by: Alexander Graf ag...@suse.de
CC: Jan Kiszka jan.kis...@siemens.com
---
 target-s390x/kvm.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 9123203..ae7dc56 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -441,7 +441,7 @@ static int handle_instruction(CPUState *env, struct kvm_run 
*run)
 if (r  0) {
 enter_pgmcheck(env, 0x0001);
 }
-return r;
+return 0;
 }
 
 static int handle_intercept(CPUState *env)
-- 
1.6.0.2




[Qemu-devel] [PATCH 09/19] linux-user: define a couple of syscalls for non-uid16 targets

2011-03-29 Thread Alexander Graf
From: Ulrich Hecht u...@suse.de

Quite a number of syscalls are only defined on systems with USE_UID16
defined; this patch defines them on other systems as well.

Fixes a large number of uid/gid-related testcases on the s390x target
(and most likely on other targets as well)

Signed-off-by: Ulrich Hecht u...@suse.de
---
 linux-user/syscall.c |  125 ++
 1 files changed, 105 insertions(+), 20 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fabe815..0bce466 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -326,7 +326,7 @@ static int sys_fchmodat(int dirfd, const char *pathname, 
mode_t mode)
   return (fchmodat(dirfd, pathname, mode, 0));
 }
 #endif
-#if defined(TARGET_NR_fchownat)  defined(USE_UID16)
+#if defined(TARGET_NR_fchownat)
 static int sys_fchownat(int dirfd, const char *pathname, uid_t owner,
 gid_t group, int flags)
 {
@@ -435,7 +435,7 @@ _syscall3(int,sys_faccessat,int,dirfd,const char 
*,pathname,int,mode)
 #if defined(TARGET_NR_fchmodat)  defined(__NR_fchmodat)
 _syscall3(int,sys_fchmodat,int,dirfd,const char *,pathname, mode_t,mode)
 #endif
-#if defined(TARGET_NR_fchownat)  defined(__NR_fchownat)  defined(USE_UID16)
+#if defined(TARGET_NR_fchownat)  defined(__NR_fchownat)
 _syscall5(int,sys_fchownat,int,dirfd,const char *,pathname,
   uid_t,owner,gid_t,group,int,flags)
 #endif
@@ -6817,18 +6817,35 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
arg1,
 case TARGET_NR_setfsgid:
 ret = get_errno(setfsgid(arg1));
 break;
+#else /* USE_UID16 */
+#if defined(TARGET_NR_fchownat)  defined(__NR_fchownat)
+case TARGET_NR_fchownat:
+if (!(p = lock_user_string(arg2)))
+goto efault;
+ret = get_errno(sys_fchownat(arg1, p, arg3, arg4, arg5));
+unlock_user(p, arg2, 0);
+break;
+#endif
 #endif /* USE_UID16 */
 
-#ifdef TARGET_NR_lchown32
+#if defined(TARGET_NR_lchown32) || !defined(USE_UID16)
+#if defined(TARGET_NR_lchown32)
 case TARGET_NR_lchown32:
+#else
+case TARGET_NR_lchown:
+#endif
 if (!(p = lock_user_string(arg1)))
 goto efault;
 ret = get_errno(lchown(p, arg2, arg3));
 unlock_user(p, arg1, 0);
 break;
 #endif
-#ifdef TARGET_NR_getuid32
+#if defined(TARGET_NR_getuid32) || (defined(TARGET_NR_getuid)  
!defined(USE_UID16))
+#if defined(TARGET_NR_getuid32)
 case TARGET_NR_getuid32:
+#else
+case TARGET_NR_getuid:
+#endif
 ret = get_errno(getuid());
 break;
 #endif
@@ -6973,33 +6990,57 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
arg1,
 break;
 #endif
 
-#ifdef TARGET_NR_getgid32
+#if defined(TARGET_NR_getgid32) || (defined(TARGET_NR_getgid)  
!defined(USE_UID16))
+#if defined(TARGET_NR_getgid32)
 case TARGET_NR_getgid32:
+#else
+case TARGET_NR_getgid:
+#endif
 ret = get_errno(getgid());
 break;
 #endif
-#ifdef TARGET_NR_geteuid32
+#if defined(TARGET_NR_geteuid32) || (defined(TARGET_NR_geteuid)  
!defined(USE_UID16))
+#if defined(TARGET_NR_geteuid32)
 case TARGET_NR_geteuid32:
+#else
+case TARGET_NR_geteuid:
+#endif
 ret = get_errno(geteuid());
 break;
 #endif
-#ifdef TARGET_NR_getegid32
+#if defined(TARGET_NR_getegid32) || (defined(TARGET_NR_getegid)  
!defined(USE_UID16))
+#if defined(TARGET_NR_getegid32)
 case TARGET_NR_getegid32:
+#else
+case TARGET_NR_getegid:
+#endif
 ret = get_errno(getegid());
 break;
 #endif
-#ifdef TARGET_NR_setreuid32
+#if defined(TARGET_NR_setreuid32) || !defined(USE_UID16)
+#if defined(TARGET_NR_setreuid32)
 case TARGET_NR_setreuid32:
+#else
+case TARGET_NR_setreuid:
+#endif
 ret = get_errno(setreuid(arg1, arg2));
 break;
 #endif
-#ifdef TARGET_NR_setregid32
+#if defined(TARGET_NR_setregid32) || !defined(USE_UID16)
+#if defined(TARGET_NR_setregid32)
 case TARGET_NR_setregid32:
+#else
+case TARGET_NR_setregid:
+#endif
 ret = get_errno(setregid(arg1, arg2));
 break;
 #endif
-#ifdef TARGET_NR_getgroups32
+#if defined(TARGET_NR_getgroups32) || !defined(USE_UID16)
+#if defined(TARGET_NR_getgroups32)
 case TARGET_NR_getgroups32:
+#else
+case TARGET_NR_getgroups:
+#endif
 {
 int gidsetsize = arg1;
 uint32_t *target_grouplist;
@@ -7023,8 +7064,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
arg1,
 }
 break;
 #endif
-#ifdef TARGET_NR_setgroups32
+#if defined(TARGET_NR_setgroups32) || !defined(USE_UID16)
+#if defined(TARGET_NR_setgroups32)
 case TARGET_NR_setgroups32:
+#else
+case TARGET_NR_setgroups:
+#endif
 {
 int gidsetsize = arg1;
 uint32_t *target_grouplist;
@@ -7044,18 +7089,30 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
arg1,
 }
 break;
 #endif
-#ifdef TARGET_NR_fchown32
+#if defined(TARGET_NR_fchown32) || !defined(USE_UID16)
+#if 

[Qemu-devel] [PATCH 12/19] s390x: Adjust GDB stub

2011-03-29 Thread Alexander Graf
We have successfully lazilized cc computation, so we need to manually
trigger its calculation when gdb wants to fetch it. We also changed the
variable name, so writing it writes into a different field now.

Signed-off-by: Alexander Graf ag...@suse.de
---
 gdbstub.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gdbstub.c b/gdbstub.c
index 1e9f931..f8b5d7e 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1431,7 +1431,11 @@ static int cpu_gdb_read_register(CPUState *env, uint8_t 
*mem_buf, int n)
 /* XXX */
 break;
 case S390_PC_REGNUM: GET_REGL(env-psw.addr); break;
-case S390_CC_REGNUM: GET_REG32(env-cc); break;
+case S390_CC_REGNUM:
+env-cc_op = calc_cc(env, env-cc_op, env-cc_src, env-cc_dst,
+ env-cc_vr);
+GET_REG32(env-cc_op);
+break;
 }
 
 return 0;
@@ -1457,7 +1461,7 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t 
*mem_buf, int n)
 /* XXX */
 break;
 case S390_PC_REGNUM: env-psw.addr = tmpl; break;
-case S390_CC_REGNUM: env-cc = tmp32; r=4; break;
+case S390_CC_REGNUM: env-cc_op = tmp32; r=4; break;
 }
 
 return r;
-- 
1.6.0.2




[Qemu-devel] [PATCH] lan9118: Ignore write to MAC_VLAN1 register

2011-03-29 Thread Atsushi Nemoto
Since kernel 2.6.38, smsc911x driver writes to VLAN1 registger.

Signed-off-by: Atsushi Nemoto an...@mba.ocn.ne.jp
---
 hw/lan9118.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/hw/lan9118.c b/hw/lan9118.c
index af6949f..62aead3 100644
--- a/hw/lan9118.c
+++ b/hw/lan9118.c
@@ -785,6 +785,8 @@ static void do_mac_write(lan9118_state *s, int reg, 
uint32_t val)
 case MAC_FLOW:
 s-mac_flow = val  0x;
 break;
+case MAC_VLAN1:
+break; /* just ignore */
 default:
 hw_error(lan9118: Unimplemented MAC register write: %d = 0x%x\n,
  s-mac_cmd  0xf, val);
-- 
1.5.6.5




[Qemu-devel] [PATCH 07/19] s390x: enable CPU_QuadU

2011-03-29 Thread Alexander Graf
From: Ulrich Hecht u...@suse.de

S390x uses the QuadU type, so let's enable it.

Signed-off-by: Ulrich Hecht u...@suse.de
---
 cpu-all.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index 4f4631d..4cc445f 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -138,7 +138,7 @@ typedef union {
 uint64_t ll;
 } CPU_DoubleU;
 
-#ifdef TARGET_SPARC
+#if defined(TARGET_SPARC) || defined(TARGET_S390X)
 typedef union {
 float128 q;
 #if defined(HOST_WORDS_BIGENDIAN) \
-- 
1.6.0.2




[Qemu-devel] [PATCH 10/19] s390x: Enable s390x-softmmu target

2011-03-29 Thread Alexander Graf
This patch adds some code paths for running s390x guest OSs without the
need for KVM.

Signed-off-by: Alexander Graf ag...@suse.de
---
 cpu-exec.c  |8 
 target-s390x/exec.h |   20 
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/cpu-exec.c b/cpu-exec.c
index 5cc9379..ebc8cba 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -343,6 +343,8 @@ int cpu_exec(CPUState *env1)
 do_interrupt(env);
 #elif defined(TARGET_M68K)
 do_interrupt(0);
+#elif defined(TARGET_S390X)
+do_interrupt(env);
 #endif
 env-exception_index = -1;
 #endif
@@ -551,6 +553,12 @@ int cpu_exec(CPUState *env1)
 do_interrupt(1);
 next_tb = 0;
 }
+#elif defined(TARGET_S390X)  !defined(CONFIG_USER_ONLY)
+if ((interrupt_request  CPU_INTERRUPT_HARD) 
+(env-psw.mask  PSW_MASK_EXT)) {
+do_interrupt(env);
+next_tb = 0;
+}
 #endif
/* Don't use the cached interupt_request value,
   do_interrupt may have updated the EXITTB flag. */
diff --git a/target-s390x/exec.h b/target-s390x/exec.h
index f7893f3..6fe64a6 100644
--- a/target-s390x/exec.h
+++ b/target-s390x/exec.h
@@ -34,6 +34,26 @@ static inline int cpu_has_work(CPUState *env)
 return env-interrupt_request  CPU_INTERRUPT_HARD; // guess
 }
 
+static inline void regs_to_env(void)
+{
+}
+
+static inline void env_to_regs(void)
+{
+}
+
+static inline int cpu_halted(CPUState *env)
+{
+if (!env-halted) {
+   return 0;
+}
+if (cpu_has_work(env)) {
+env-halted = 0;
+return 0;
+}
+return EXCP_HALTED;
+}
+
 static inline void cpu_pc_from_tb(CPUState *env, TranslationBlock* tb)
 {
 env-psw.addr = tb-pc;
-- 
1.6.0.2




[Qemu-devel] [PATCH 14/19] s390x: Prepare cpu.h for emulation

2011-03-29 Thread Alexander Graf
We need to add some more logic to the CPU description to leverage emulation
of an s390x CPU. This patch adds all the required helpers, fields in CPUState
and constant definitions required for user and system emulation.

Signed-off-by: Alexander Graf ag...@suse.de

---

v1 - v2:

  - remove FPReg definition
  - remove EXCP_EXECUTE_SVC in non user-mode
  - add descriptions to more cc_ops
  - add comment on time2tod
  - remove redundant EXECUTE_SVC
  - describe EXCP_EXT
---
 target-s390x/cpu.h |  770 +---
 1 files changed, 726 insertions(+), 44 deletions(-)

diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index e47c372..0d9c4f2 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -26,24 +26,35 @@
 #define CPUState struct CPUS390XState
 
 #include cpu-defs.h
+#define TARGET_PAGE_BITS 12
+
+#define TARGET_PHYS_ADDR_SPACE_BITS 64
+#define TARGET_VIRT_ADDR_SPACE_BITS 64
+
+#include cpu-all.h
 
 #include softfloat.h
 
-#define NB_MMU_MODES 2
+#define NB_MMU_MODES 3
 
-typedef union FPReg {
-struct {
-#ifdef WORDS_BIGENDIAN
-float32 e;
-int32_t __pad;
-#else
-int32_t __pad;
-float32 e;
-#endif
-};
-float64 d;
-uint64_t i;
-} FPReg;
+#define MMU_MODE0_SUFFIX _primary
+#define MMU_MODE1_SUFFIX _secondary
+#define MMU_MODE2_SUFFIX _home
+
+#define MMU_USER_IDX 1
+
+#define MAX_EXT_QUEUE 16
+
+typedef struct PSW {
+uint64_t mask;
+uint64_t addr;
+} PSW;
+
+typedef struct ExtQueue {
+uint32_t code;
+uint32_t param;
+uint32_t param64;
+} ExtQueue;
 
 typedef struct CPUS390XState {
 uint64_t regs[16]; /* GP registers */
@@ -51,17 +62,41 @@ typedef struct CPUS390XState {
 uint32_t aregs[16];/* access registers */
 
 uint32_t fpc;  /* floating-point control register */
-FPReg fregs[16]; /* FP registers */
+CPU_DoubleU fregs[16]; /* FP registers */
 float_status fpu_status; /* passed to softfloat lib */
 
-struct {
-uint64_t mask;
-uint64_t addr;
-} psw;
+PSW psw;
 
-int cc; /* condition code (0-3) */
+uint32_t cc_op;
+uint64_t cc_src;
+uint64_t cc_dst;
+uint64_t cc_vr;
 
 uint64_t __excp_addr;
+uint64_t psa;
+
+uint32_t int_pgm_code;
+uint32_t int_pgm_ilc;
+
+uint32_t int_svc_code;
+uint32_t int_svc_ilc;
+
+uint64_t cregs[16]; /* control registers */
+
+int pending_int;
+ExtQueue ext_queue[MAX_EXT_QUEUE];
+
+/* reset does memset(0) up to here */
+
+int ext_index;
+int cpu_num;
+uint8_t *storage_keys;
+
+uint64_t tod_offset;
+uint64_t tod_basetime;
+QEMUTimer *tod_timer;
+
+QEMUTimer *cpu_timer;
 
 CPU_COMMON
 } CPUS390XState;
@@ -69,24 +104,174 @@ typedef struct CPUS390XState {
 #if defined(CONFIG_USER_ONLY)
 static inline void cpu_clone_regs(CPUState *env, target_ulong newsp)
 {
-if (newsp)
+if (newsp) {
 env-regs[15] = newsp;
+}
 env-regs[0] = 0;
 }
 #endif
 
-#define MMU_MODE0_SUFFIX _kernel
-#define MMU_MODE1_SUFFIX _user
-#define MMU_USER_IDX 1
+/* Interrupt Codes */
+/* Program Interrupts */
+#define PGM_OPERATION   0x0001
+#define PGM_PRIVILEGED  0x0002
+#define PGM_EXECUTE 0x0003
+#define PGM_PROTECTION  0x0004
+#define PGM_ADDRESSING  0x0005
+#define PGM_SPECIFICATION   0x0006
+#define PGM_DATA0x0007
+#define PGM_FIXPT_OVERFLOW  0x0008
+#define PGM_FIXPT_DIVIDE0x0009
+#define PGM_DEC_OVERFLOW0x000a
+#define PGM_DEC_DIVIDE  0x000b
+#define PGM_HFP_EXP_OVERFLOW0x000c
+#define PGM_HFP_EXP_UNDERFLOW   0x000d
+#define PGM_HFP_SIGNIFICANCE0x000e
+#define PGM_HFP_DIVIDE  0x000f
+#define PGM_SEGMENT_TRANS   0x0010
+#define PGM_PAGE_TRANS  0x0011
+#define PGM_TRANS_SPEC  0x0012
+#define PGM_SPECIAL_OP  0x0013
+#define PGM_OPERAND 0x0015
+#define PGM_TRACE_TABLE 0x0016
+#define PGM_SPACE_SWITCH0x001c
+#define PGM_HFP_SQRT0x001d
+#define PGM_PC_TRANS_SPEC   0x001f
+#define PGM_AFX_TRANS   0x0020
+#define PGM_ASX_TRANS   0x0021
+#define PGM_LX_TRANS0x0022
+#define PGM_EX_TRANS0x0023
+#define PGM_PRIM_AUTH   0x0024
+#define PGM_SEC_AUTH0x0025
+#define PGM_ALET_SPEC   0x0028
+#define PGM_ALEN_SPEC   0x0029
+#define PGM_ALE_SEQ 0x002a
+#define PGM_ASTE_VALID  0x002b
+#define PGM_ASTE_SEQ0x002c
+#define PGM_EXT_AUTH0x002d
+#define PGM_STACK_FULL  0x0030
+#define PGM_STACK_EMPTY 0x0031
+#define PGM_STACK_SPEC 

[Qemu-devel] [PATCH 00/19] s390x emulation support

2011-03-29 Thread Alexander Graf
We've had support for running s390x guests with KVM for a
while now. This patch set also enables support for running
s390x guests in system as well as linux-user mode in emulation!

Within this scope, I again want to stress that this is _not_
supposed to replace Hercules - the s390 emulator - in any way.
The only target supported by qemu is Linux. You can only run
Linux applications with linux-user emulation and Linux guest OSs
with the system emulation. All the device logic (and 24 bit mode)
for running legacy stuff is missing. Use Hercules for those!

I have successfully run the following guest OSs:

  - SUSE Linux Enterprise Server 11 SP1
  - Debian Lenny

Both of which work just fine on x86_64 and ppc hosts. Other hosts
should also work. The only thing that did not work for me is network.
Somehow networking only works with KVM enabled, so there is probably
some bug involved still.

Either way - rejoice! As with this patch set you can finally fulfill
your mainframe desires on your local workstation. And - most importantly -
finally test patches to virtio against s390!

For images, I'm hoping for Aurelien to provide Debian images that run
in qemu. Other distributions only provide S390x target support in their
enterprise variants, keeping me from redistributing images :(.

If you're trying to get things rolling yourself, make sure to use a
recent kernel that has support for the virtio architecture and virtio
console support - otherwise you won't see output.

The linux user mode emulation part only support 64bit binaries, so
running Debian binaries with that one is out of question for now. Use
the system emulation mode if you really need to run Debian binaries.

For the lazy ones:

git://repo.or.cz/qemu/agraf.git s390-tcg-v2

v1 - v2:

  - fix broken s390-virtio-serial
  - fix broken s390 kvm target
  - always set 64bit flag for s390x binaries in elf loader
  - remove redundant EXECUTE_SVC
  - advance psw.addr in syscall execution path
  - remove FPReg definition
  - add descriptions to more cc_ops
  - add comment on time2tod
  - describe EXCP_EXT
  - use new clock syntax
  - use float_chs
  - use float compare built-ins
  - remove redundant EXECUTE_SVC
  - don't pass env into DisasContext
  - remove if 0'd code
  - truncate at 80 chars
  - enable disas debug by default (-d in_asm)
  - remove explicit psw.addr advancing on SVC

Alexander Graf (14):
  Only build ivshmem when CONFIG_PCI  CONFIG_KVM
  virtio: use generic name when possible
  s390x: fix KVM target
  s390x: fix s390-virtio-serial
  s390x: Enable s390x-softmmu target
  s390x: Dispatch interrupts to KVM or the real CPU
  s390x: Adjust GDB stub
  s390x: virtio machine storage keys
  s390x: Prepare cpu.h for emulation
  s390x: helper functions for system emulation
  s390x: Implement opcode helpers
  s390x: Adjust internal kvm code
  s390x: translate engine for s390x CPU
  s390x: build s390x by default

Ulrich Hecht (5):
  s390x: Enable disassembler for s390x
  s390x: Enable nptl for s390x
  s390x: enable CPU_QuadU
  s390x: s390x-linux-user support
  linux-user: define a couple of syscalls for non-uid16 targets

 Makefile.target  |8 +-
 blockdev.c   |2 +-
 configure|3 +
 cpu-all.h|2 +-
 cpu-exec.c   |8 +
 default-configs/s390x-linux-user.mak |1 +
 disas.c  |6 +
 gdbstub.c|8 +-
 hw/s390-virtio-bus.c |   18 +-
 hw/s390-virtio-bus.h |4 +-
 hw/s390-virtio.c |   21 +-
 hw/virtio-pci.c  |3 +
 linux-user/elfload.c |   19 +
 linux-user/main.c|   83 +
 linux-user/s390x/syscall.h   |   25 +
 linux-user/s390x/syscall_nr.h|  349 +++
 linux-user/s390x/target_signal.h |   26 +
 linux-user/s390x/termbits.h  |  283 ++
 linux-user/signal.c  |  314 +++
 linux-user/syscall.c |  143 +-
 linux-user/syscall_defs.h|   56 +-
 s390x.ld |  194 ++
 scripts/qemu-binfmt-conf.sh  |4 +-
 target-s390x/cpu.h   |  770 +-
 target-s390x/exec.h  |   20 +
 target-s390x/helper.c|  581 -
 target-s390x/helpers.h   |  151 +
 target-s390x/kvm.c   |   62 +-
 target-s390x/op_helper.c | 2880 +++-
 target-s390x/translate.c | 5116 +-
 vl.c |6 +-
 31 files changed, 11005 insertions(+), 161 deletions(-)
 create mode 100644 default-configs/s390x-linux-user.mak
 create mode 100644 linux-user/s390x/syscall.h
 create mode 100644 linux-user/s390x/syscall_nr.h
 create mode 100644 linux-user/s390x/target_signal.h
 create mode 100644 linux-user/s390x/termbits.h
 create mode 100644 

[Qemu-devel] [PATCH 15/19] s390x: helper functions for system emulation

2011-03-29 Thread Alexander Graf
When running system emulation, we need to transverse through the MMU and
deliver interrupts according to the specification.

This patch implements those two pieces and in addition adjusts the CPU
initialization code to account for the new fields in CPUState.

Signed-off-by: Alexander Graf ag...@suse.de

---

v1 - v2:

  - new clock syntax
---
 target-s390x/helper.c |  581 -
 1 files changed, 571 insertions(+), 10 deletions(-)

diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index 4a5297b..bae3adb 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -2,6 +2,7 @@
  *  S/390 helpers
  *
  *  Copyright (c) 2009 Ulrich Hecht
+ *  Copyright (c) 2011 Alexander Graf
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,27 +26,108 @@
 #include exec-all.h
 #include gdbstub.h
 #include qemu-common.h
+#include qemu-timer.h
 
+#if !defined(CONFIG_USER_ONLY)
 #include linux/kvm.h
 #include kvm.h
+#endif
+
+//#define S390_PTE_PRINTF_HACK
+//#define DEBUG_S390
+//#define DEBUG_S390_PTE
+//#define DEBUG_S390_STDOUT
+
+#ifdef DEBUG_S390
+#ifdef DEBUG_S390_STDOUT
+#define dprintf(fmt, ...) \
+do { fprintf(stderr, fmt, ## __VA_ARGS__); \
+ qemu_log(fmt, ##__VA_ARGS__); } while (0)
+#else
+#define dprintf(fmt, ...) \
+do { qemu_log(fmt, ## __VA_ARGS__); } while (0)
+#endif
+#else
+#define dprintf(fmt, ...) \
+do { } while (0)
+#endif
+
+#ifdef DEBUG_S390_PTE
+#define pte_dprintf dprintf
+#else
+#define pte_dprintf(fmt, ...) \
+do { } while (0)
+#endif
+
+#ifndef CONFIG_USER_ONLY
+static void s390x_tod_timer(void *opaque)
+{
+CPUState *env = opaque;
+
+env-pending_int |= INTERRUPT_TOD;
+cpu_interrupt(env, CPU_INTERRUPT_HARD);
+}
+
+static void s390x_cpu_timer(void *opaque)
+{
+CPUState *env = opaque;
+
+env-pending_int |= INTERRUPT_CPUTIMER;
+cpu_interrupt(env, CPU_INTERRUPT_HARD);
+}
+#endif
 
 CPUS390XState *cpu_s390x_init(const char *cpu_model)
 {
 CPUS390XState *env;
+#if !defined (CONFIG_USER_ONLY)
+struct tm tm;
+#endif
 static int inited = 0;
+static int cpu_num = 0;
 
 env = qemu_mallocz(sizeof(CPUS390XState));
 cpu_exec_init(env);
 if (!inited) {
 inited = 1;
+s390x_translate_init();
 }
 
+#if !defined(CONFIG_USER_ONLY)
+qemu_get_timedate(tm, 0);
+env-tod_offset = TOD_UNIX_EPOCH +
+  (time2tod(mktimegm(tm)) * 10ULL);
+env-tod_basetime = 0;
+env-tod_timer = qemu_new_timer_ns(vm_clock, s390x_tod_timer, env);
+env-cpu_timer = qemu_new_timer_ns(vm_clock, s390x_cpu_timer, env);
+#endif
 env-cpu_model_str = cpu_model;
+env-cpu_num = cpu_num++;
+env-ext_index = -1;
 cpu_reset(env);
 qemu_init_vcpu(env);
 return env;
 }
 
+#if defined(CONFIG_USER_ONLY)
+
+void do_interrupt (CPUState *env)
+{
+env-exception_index = -1;
+}
+
+int cpu_s390x_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
+  int mmu_idx, int is_softmmu)
+{
+/* fprintf(stderr,%s: address 0x%lx rw %d mmu_idx %d is_softmmu %d\n,
+__FUNCTION__, address, rw, mmu_idx, is_softmmu); */
+env-exception_index = EXCP_ADDR;
+env-__excp_addr = address; /* FIXME: find out how this works on a real 
machine */
+return 1;
+}
+
+#endif /* CONFIG_USER_ONLY */
+
 void cpu_reset(CPUS390XState *env)
 {
 if (qemu_loglevel_mask(CPU_LOG_RESET)) {
@@ -53,32 +135,511 @@ void cpu_reset(CPUS390XState *env)
 log_cpu_state(env, 0);
 }
 
-memset(env, 0, offsetof(CPUS390XState, breakpoints));
+memset(env, 0, offsetof(CPUS390XState, cpu_num));
 /* FIXME: reset vector? */
 tlb_flush(env, 1);
 }
 
-target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
+#ifndef CONFIG_USER_ONLY
+
+/* Ensure to exit the TB after this call! */
+static void trigger_pgm_exception(CPUState *env, uint32_t code, uint32_t ilc)
+{
+env-exception_index = EXCP_PGM;
+env-int_pgm_code = code;
+env-int_pgm_ilc = ilc;
+}
+
+static int trans_bits(CPUState *env, uint64_t mode)
+{
+int bits = 0;
+
+switch (mode) {
+case PSW_ASC_PRIMARY:
+bits = 1;
+break;
+case PSW_ASC_SECONDARY:
+bits = 2;
+break;
+case PSW_ASC_HOME:
+bits = 3;
+break;
+default:
+cpu_abort(env, unknown asc mode\n);
+break;
+}
+
+return bits;
+}
+
+static void trigger_prot_fault(CPUState *env, target_ulong vaddr, uint64_t 
mode)
+{
+int ilc = ILC_LATER_INC_2;
+int bits = trans_bits(env, mode) | 4;
+
+dprintf(%s: vaddr=%016 PRIx64  bits=%d\n, __FUNCTION__, vaddr, bits);
+#ifdef S390_PTE_PRINTF_HACK
+fprintf(stderr, %s: vaddr=%016 PRIx64  bits=%d\n, __FUNCTION__, vaddr, 
bits);
+#endif
+
+stq_phys(env-psa + offsetof(LowCore, trans_exc_code), vaddr | bits);
+trigger_pgm_exception(env, 

[Qemu-devel] [PATCH 19/19] s390x: build s390x by default

2011-03-29 Thread Alexander Graf
This patch enables building of s390x-softmmu and s390x-linux-user
targets by default.

Signed-off-by: Alexander Graf ag...@suse.de
---
 configure|2 ++
 default-configs/s390x-linux-user.mak |1 +
 2 files changed, 3 insertions(+), 0 deletions(-)
 create mode 100644 default-configs/s390x-linux-user.mak

diff --git a/configure b/configure
index 978fd1f..e9f5976 100755
--- a/configure
+++ b/configure
@@ -1004,6 +1004,7 @@ sh4-softmmu \
 sh4eb-softmmu \
 sparc-softmmu \
 sparc64-softmmu \
+s390x-softmmu \
 
 fi
 # the following are Linux specific
@@ -1028,6 +1029,7 @@ sh4eb-linux-user \
 sparc-linux-user \
 sparc64-linux-user \
 sparc32plus-linux-user \
+s390x-linux-user \
 
 fi
 # the following are Darwin specific
diff --git a/default-configs/s390x-linux-user.mak 
b/default-configs/s390x-linux-user.mak
new file mode 100644
index 000..a243c99
--- /dev/null
+++ b/default-configs/s390x-linux-user.mak
@@ -0,0 +1 @@
+# Default configuration for s390x-linux-user
-- 
1.6.0.2




[Qemu-devel] Fedora Virt status

2011-03-29 Thread Justin M. Forbes
Fedora 14
- We have 91 open bugs, 10 of which have fixes in awaiting updates.
- 7 bugs have been closed in the last week

Fedora 15
- Upcoming Deadlines:
  2011-03-29  Software Translation Deadline
  2011-04-05  Beta Change Deadline Features 100% Complete
  2011-04-19  Beta Release
  2011-05-09  Final Change Deadline
  2011-05-10  Compose 'Final' RC
  2011-05-24  Fedora 15 Final Release

- Virtualization Test Day is coming up on Thursday, April 14th.  Please
  mark your calendars, and join us for testing and bug hunting.  The more
  we can uncover before release, the better off we are.

- There are currently 56 bugs open against rawhide/F15.

 == Updates Needing review ==
  The following packages are in updates-testing and need review and karma as
  appropriate:

  F13:
  - libvirt-0.8.2-3.fc13
fix a lack of API check on read-only connections this build fix one crash in
the the error handling fix a lack of API check on read-only connections

  F14:
  - libvirt-0.8.3-6.fc14
fix a lack of API check on read-only connections this build fix one crash in
the the error handling fix a lack of API check on read-only connections

  == Virt Preview Repository ==
  The virt-preview repository is now active for F14 users wishing to run the
  latest F15 virt packages on their stable F14 systems.  F13 virt-preview users
  will still get the latest F14 packages.  For details on how to run enable 
  virt-preview, please see:
  https://fedoraproject.org/wiki/Virtualization_Preview_Repository

  == Bugs of importance: ==
- 679179 Openbios-ppc subpackage disappeared
  It has been decided to drop the qemu-system-ppc and qemu-system-sparc as they
  offer limited use with modern linux systems

- 681220 Virtual machines using the qxl driver crash
  This has been fixed and updates are available in F15 and F14 virt-preview




Re: [Qemu-devel] [PATCH 0/2] avoid races on exec migration

2011-03-29 Thread Anthony Liguori

On 03/09/2011 11:21 AM, Paolo Bonzini wrote:

QEMU has a sigchld handler that reaps any child process.  -smb is the
only user of it and, in fact, QEMU inherited it from slirp.  However,
this handler causes 'exec' based migration to randomly return 'status:
failed' in the monitor.  This happens when the signal handler for SIGCHLD
is ran before the pclose() of exec migration.

The return status of fclose() is passed back as return status of
qemu_fclose().  If qemu_fclose() fails, then the exec_close() in
migration-exec.c returns a error code. This causes migrate_fd_cleanup()
to return an error, and thus finally we see why 'status: failed' occurs:

 if (migrate_fd_cleanup(s)  0) {
 if (old_vm_running) {
 vm_start();
 }
 state = MIG_STATE_ERROR;
 }

To avoid this, register the pids in a list and, on SIGCHLD, set up a
bottom-half that would go through the pids and reap them.

Since I'm at it, I'm moving iohandler stuff out of vl.c.  The new
file isn't a perfect place to add the child watcher, but it's arguably
better than vl.c.

This should be applied to both master and stable.


Applied all.  Thanks.

Regards,

Anthony Liguori


Paolo Bonzini (2):
   extract I/O handler lists to iohandler.c
   add a service to reap zombies

  Makefile.objs |2 +-
  iohandler.c   |  193 +
  os-posix.c|9 ---
  qemu-common.h |4 +
  slirp/misc.c  |5 +-
  vl.c  |  106 ++--
  6 files changed, 207 insertions(+), 112 deletions(-)
  create mode 100644 iohandler.c






[Qemu-devel] [PATCH v3 3/7] vl.c: Fix machine registration so QEMUMachine structs can be const

2011-03-29 Thread Peter Maydell
Reimplement the list of QEMUMachine structures so that we don't keep the
'next' pointer inside the QEMUMachine struct itself. This allows us to
accept a const struct pointer in qemu_register_machine. The few places
in vl.c which were implicitly assuming that QEMUMachine structs were
writable have been updated.

We also take the opportunity to correct the return type of
qemu_register_machine from 'int' to 'void', since it can never fail
and none of its callers check the return value.

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
 hw/boards.h |5 +--
 vl.c|   99 ++
 2 files changed, 60 insertions(+), 44 deletions(-)

diff --git a/hw/boards.h b/hw/boards.h
index 5f41fce..731d8c7 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -29,11 +29,10 @@ typedef struct QEMUMachine {
 no_sdcard:1;
 int is_default;
 GlobalProperty *compat_props;
-struct QEMUMachine *next;
 } QEMUMachine;
 
-int qemu_register_machine(QEMUMachine *m);
+void qemu_register_machine(const QEMUMachine *m);
 
-extern QEMUMachine *current_machine;
+extern const QEMUMachine *current_machine;
 
 #endif
diff --git a/vl.c b/vl.c
index 69cb29b..d58bbf8 100644
--- a/vl.c
+++ b/vl.c
@@ -1090,45 +1090,62 @@ int qemu_set_fd_handler(int fd,
 /***/
 /* machine registration */
 
-static QEMUMachine *first_machine = NULL;
-QEMUMachine *current_machine = NULL;
+typedef struct QEMUMachineListEntry {
+QTAILQ_ENTRY(QEMUMachineListEntry) entry;
+const QEMUMachine *machine;
+} QEMUMachineListEntry;
 
-int qemu_register_machine(QEMUMachine *m)
+static QTAILQ_HEAD(machine_list, QEMUMachineListEntry) machine_list =
+QTAILQ_HEAD_INITIALIZER(machine_list);
+
+const QEMUMachine *current_machine = NULL;
+
+void qemu_register_machine(const QEMUMachine *m)
 {
-QEMUMachine **pm;
-pm = first_machine;
-while (*pm != NULL)
-pm = (*pm)-next;
-m-next = NULL;
-*pm = m;
-return 0;
+QEMUMachineListEntry *me = qemu_mallocz(sizeof(QEMUMachineListEntry));
+me-machine = m;
+QTAILQ_INSERT_TAIL(machine_list, me, entry);
 }
 
-static QEMUMachine *find_machine(const char *name)
+static const QEMUMachine *find_machine(const char *name)
 {
-QEMUMachine *m;
+QEMUMachineListEntry *me;
 
-for(m = first_machine; m != NULL; m = m-next) {
-if (!strcmp(m-name, name))
-return m;
-if (m-alias  !strcmp(m-alias, name))
-return m;
+QTAILQ_FOREACH(me, machine_list, entry) {
+if (!strcmp(me-machine-name, name)) {
+return me-machine;
+}
+if (me-machine-alias  !strcmp(me-machine-alias, name)) {
+return me-machine;
+}
 }
 return NULL;
 }
 
-static QEMUMachine *find_default_machine(void)
+static const QEMUMachine *find_default_machine(void)
 {
-QEMUMachine *m;
-
-for(m = first_machine; m != NULL; m = m-next) {
-if (m-is_default) {
-return m;
+QEMUMachineListEntry *me;
+QTAILQ_FOREACH(me, machine_list, entry) {
+if (me-machine-is_default) {
+return me-machine;
 }
 }
 return NULL;
 }
 
+static void print_machines(void)
+{
+QEMUMachineListEntry *me;
+QTAILQ_FOREACH(me, machine_list, entry) {
+const QEMUMachine *m = me-machine;
+if (m-alias) {
+printf(%-10s %s (alias of %s)\n, m-alias, m-desc, m-name);
+}
+printf(%-10s %s%s\n, m-name, m-desc,
+   m-is_default ?  (default) : );
+}
+}
+
 /***/
 /* main execution loop */
 
@@ -2050,7 +2067,7 @@ int main(int argc, char **argv, char **envp)
 int optind;
 const char *optarg;
 const char *loadvm = NULL;
-QEMUMachine *machine;
+const QEMUMachine *machine;
 const char *cpu_model;
 int tb_size;
 const char *pid_file = NULL;
@@ -2146,16 +2163,8 @@ int main(int argc, char **argv, char **envp)
 case QEMU_OPTION_M:
 machine = find_machine(optarg);
 if (!machine) {
-QEMUMachine *m;
 printf(Supported machines are:\n);
-for(m = first_machine; m != NULL; m = m-next) {
-if (m-alias)
-printf(%-10s %s (alias of %s)\n,
-   m-alias, m-desc, m-name);
-printf(%-10s %s%s\n,
-   m-name, m-desc,
-   m-is_default ?  (default) : );
-}
+print_machines();
 exit(*optarg != '?');
 }
 break;
@@ -2926,12 +2935,14 @@ int main(int argc, char **argv, char **envp)
 if (!max_cpus)
 max_cpus = smp_cpus;
 
-machine-max_cpus = machine-max_cpus ?: 1; /* Default to UP */
-if (smp_cpus  

[Qemu-devel] [PATCH 08/19] s390x: s390x-linux-user support

2011-03-29 Thread Alexander Graf
From: Ulrich Hecht u...@suse.de

This patch adds support for running s390x binaries in the linux-user emulation
code.

Signed-off-by: Ulrich Hecht u...@suse.de
Signed-off-by: Alexander Graf ag...@suse.de

---

v1 - v2:

  - always set 64bit flag for s390x binaries in elf loader
  - remove redundant EXECUTE_SVC
  - advance psw.addr in syscall execution path
---
 linux-user/elfload.c |   19 ++
 linux-user/main.c|   83 +
 linux-user/s390x/syscall.h   |   25 +++
 linux-user/s390x/syscall_nr.h|  349 ++
 linux-user/s390x/target_signal.h |   26 +++
 linux-user/s390x/termbits.h  |  283 ++
 linux-user/signal.c  |  314 ++
 linux-user/syscall.c |   18 ++-
 linux-user/syscall_defs.h|   56 ++-
 s390x.ld |  194 +
 scripts/qemu-binfmt-conf.sh  |4 +-
 11 files changed, 1363 insertions(+), 8 deletions(-)
 create mode 100644 linux-user/s390x/syscall.h
 create mode 100644 linux-user/s390x/syscall_nr.h
 create mode 100644 linux-user/s390x/target_signal.h
 create mode 100644 linux-user/s390x/termbits.h
 create mode 100644 s390x.ld

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index fe5410e..489f839 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -793,6 +793,25 @@ static inline void init_thread(struct target_pt_regs *regs,
 
 #endif /* TARGET_ALPHA */
 
+#ifdef TARGET_S390X
+
+#define ELF_START_MMAP (0x200ULL)
+
+#define elf_check_arch(x) ( (x) == ELF_ARCH )
+
+#define ELF_CLASS  ELFCLASS64
+#define ELF_DATA   ELFDATA2MSB
+#define ELF_ARCH   EM_S390
+
+static inline void init_thread(struct target_pt_regs *regs, struct image_info 
*infop)
+{
+regs-psw.addr = infop-entry;
+regs-psw.mask = PSW_MASK_64 | PSW_MASK_32;
+regs-gprs[15] = infop-start_stack;
+}
+
+#endif /* TARGET_S390X */
+
 #ifndef ELF_PLATFORM
 #define ELF_PLATFORM (NULL)
 #endif
diff --git a/linux-user/main.c b/linux-user/main.c
index e651bfd..362b8cb 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2624,6 +2624,80 @@ void cpu_loop (CPUState *env)
 }
 #endif /* TARGET_ALPHA */
 
+#ifdef TARGET_S390X
+void cpu_loop(CPUS390XState *env)
+{
+int trapnr;
+target_siginfo_t info;
+
+while (1) {
+trapnr = cpu_s390x_exec (env);
+
+switch (trapnr) {
+case EXCP_INTERRUPT:
+/* just indicate that signals should be handled asap */
+break;
+case EXCP_DEBUG:
+{
+int sig;
+
+sig = gdb_handlesig (env, TARGET_SIGTRAP);
+if (sig) {
+info.si_signo = sig;
+info.si_errno = 0;
+info.si_code = TARGET_TRAP_BRKPT;
+queue_signal(env, info.si_signo, info);
+}
+}
+break;
+case EXCP_SVC:
+{
+int n = env-int_svc_code;
+if (!n) {
+/* syscalls  255 */
+n = env-regs[1];
+}
+env-psw.addr += env-int_svc_ilc;
+env-regs[2] = do_syscall(env, n,
+   env-regs[2],
+   env-regs[3],
+   env-regs[4],
+   env-regs[5],
+   env-regs[6],
+   env-regs[7]);
+}
+break;
+case EXCP_ADDR:
+{
+info.si_signo = SIGSEGV;
+info.si_errno = 0;
+/* XXX: check env-error_code */
+info.si_code = TARGET_SEGV_MAPERR;
+info._sifields._sigfault._addr = env-__excp_addr;
+queue_signal(env, info.si_signo, info);
+}
+break;
+case EXCP_SPEC:
+{
+fprintf(stderr,specification exception insn 0x%08x%04x\n, 
ldl(env-psw.addr), lduw(env-psw.addr + 4));
+info.si_signo = SIGILL;
+info.si_errno = 0;
+info.si_code = TARGET_ILL_ILLOPC;
+info._sifields._sigfault._addr = env-__excp_addr;
+queue_signal(env, info.si_signo, info);
+}
+break;
+default:
+printf (Unhandled trap: 0x%x\n, trapnr);
+cpu_dump_state(env, stderr, fprintf, 0);
+exit (1);
+}
+process_pending_signals (env);
+}
+}
+
+#endif /* TARGET_S390X */
+
 static void version(void)
 {
 printf(qemu- TARGET_ARCH  version  QEMU_VERSION QEMU_PKGVERSION
@@ -3363,6 +3437,15 @@ int main(int argc, char **argv, char **envp)
env-regs[15] = regs-acr;  
env-pc = regs-erp;
 }
+#elif defined(TARGET_S390X)
+{
+int i;
+for (i = 0; i  16; i++) {
+

[Qemu-devel] [PATCH v3 1/7] Allow boards to specify maximum RAM size

2011-03-29 Thread Peter Maydell
Allow boards to specify their maximum RAM size in the QEMUMachine struct.
This allows us to provide a useful diagnostic if the user tries to specify
a RAM size that the board cannot support.

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
 hw/boards.h |1 +
 vl.c|   16 +++-
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/hw/boards.h b/hw/boards.h
index 6f0f0d7..5f41fce 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -19,6 +19,7 @@ typedef struct QEMUMachine {
 QEMUMachineInitFunc *init;
 int use_scsi;
 int max_cpus;
+target_phys_addr_t max_ram;
 unsigned int no_serial:1,
 no_parallel:1,
 use_virtcon:1,
diff --git a/vl.c b/vl.c
index 192a240..69cb29b 100644
--- a/vl.c
+++ b/vl.c
@@ -166,6 +166,9 @@ int main(int argc, char **argv)
 //#define DEBUG_NET
 //#define DEBUG_SLIRP
 
+/* Note that this default RAM size is capped to any maximum
+ * RAM size specified in the board's QEMUMachine struct.
+ */
 #define DEFAULT_RAM_SIZE 128
 
 #define MAX_VIRTIO_CONSOLES 1
@@ -3046,8 +3049,19 @@ int main(int argc, char **argv, char **envp)
 exit(1);
 
 /* init the memory */
-if (ram_size == 0)
+if (ram_size == 0) {
 ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
+if (machine-max_ram) {
+ram_size = MIN(ram_size, machine-max_ram);
+}
+} else if (machine-max_ram  ram_size  machine-max_ram) {
+/* Since you can only specify ram_size on the command line in MB it's
+ * OK to round down when printing the machine's maximum.
+ */
+fprintf(stderr, qemu: maximum permitted RAM size for '%s' is %ldM\n,
+machine-name, (ram_addr_t)(machine-max_ram / (1024 * 1024)));
+exit(1);
+}
 
 /* init the dynamic translator */
 cpu_exec_init_all(tb_size * 1024 * 1024);
-- 
1.7.1




[Qemu-devel] [PATCH v3 7/7] hw: Make QEMUMachine structure definitions const

2011-03-29 Thread Peter Maydell
Now that qemu_register_machine() accepts a const QEMUMachine *, we can
mark all the static QEMUMachine structure definitions for boards as
being const.

This patch was mostly automatically generated via:
sed -i -e 's/^static QEMUMachine /static const QEMUMachine /' hw/*.c
and then checked for completeness with a grep for QEMUMachine, which
showed up the mips_fulong2e and leon3 machines which were missing a
'static' (which has been added here).

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
 hw/an5206.c   |2 +-
 hw/axis_dev88.c   |2 +-
 hw/dummy_m68k.c   |2 +-
 hw/etraxfs.c  |2 +-
 hw/gumstix.c  |4 ++--
 hw/integratorcp.c |2 +-
 hw/leon3.c|2 +-
 hw/lm32_boards.c  |4 ++--
 hw/mainstone.c|2 +-
 hw/mcf5208.c  |2 +-
 hw/mips_fulong2e.c|2 +-
 hw/mips_jazz.c|4 ++--
 hw/mips_malta.c   |2 +-
 hw/mips_mipssim.c |2 +-
 hw/mips_r4k.c |2 +-
 hw/musicpal.c |2 +-
 hw/nseries.c  |4 ++--
 hw/omap_sx1.c |4 ++--
 hw/palm.c |2 +-
 hw/pc_piix.c  |   12 ++--
 hw/petalogix_ml605_mmu.c  |2 +-
 hw/petalogix_s3adsp1800_mmu.c |2 +-
 hw/ppc405_boards.c|4 ++--
 hw/ppc440_bamboo.c|4 ++--
 hw/ppc_newworld.c |2 +-
 hw/ppc_oldworld.c |2 +-
 hw/ppc_prep.c |2 +-
 hw/ppce500_mpc8544ds.c|2 +-
 hw/r2d.c  |2 +-
 hw/realview.c |8 
 hw/s390-virtio.c  |2 +-
 hw/shix.c |2 +-
 hw/spitz.c|8 
 hw/stellaris.c|4 ++--
 hw/sun4u.c|6 +++---
 hw/syborg.c   |2 +-
 hw/tosa.c |2 +-
 hw/versatilepb.c  |4 ++--
 hw/virtex_ml507.c |2 +-
 hw/xen_machine_pv.c   |2 +-
 40 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/hw/an5206.c b/hw/an5206.c
index b9f19a9..8bd70fe 100644
--- a/hw/an5206.c
+++ b/hw/an5206.c
@@ -87,7 +87,7 @@ static void an5206_init(ram_addr_t ram_size,
 env-pc = entry;
 }
 
-static QEMUMachine an5206_machine = {
+static const QEMUMachine an5206_machine = {
 .name = an5206,
 .desc = Arnewsh 5206,
 .init = an5206_init,
diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c
index 57b5e2f..0aef171 100644
--- a/hw/axis_dev88.c
+++ b/hw/axis_dev88.c
@@ -343,7 +343,7 @@ void axisdev88_init (ram_addr_t ram_size,
 cris_load_image(env, li);
 }
 
-static QEMUMachine axisdev88_machine = {
+static const QEMUMachine axisdev88_machine = {
 .name = axis-dev88,
 .desc = AXIS devboard 88,
 .init = axisdev88_init,
diff --git a/hw/dummy_m68k.c b/hw/dummy_m68k.c
index 61efb39..1954282 100644
--- a/hw/dummy_m68k.c
+++ b/hw/dummy_m68k.c
@@ -66,7 +66,7 @@ static void dummy_m68k_init(ram_addr_t ram_size,
 env-pc = entry;
 }
 
-static QEMUMachine dummy_m68k_machine = {
+static const QEMUMachine dummy_m68k_machine = {
 .name = dummy,
 .desc = Dummy board,
 .init = dummy_m68k_init,
diff --git a/hw/etraxfs.c b/hw/etraxfs.c
index 5ee5f97..7a92b7a 100644
--- a/hw/etraxfs.c
+++ b/hw/etraxfs.c
@@ -145,7 +145,7 @@ void bareetraxfs_init (ram_addr_t ram_size,
 }
 }
 
-static QEMUMachine bareetraxfs_machine = {
+static const QEMUMachine bareetraxfs_machine = {
 .name = bareetraxfs,
 .desc = Bare ETRAX FS board,
 .init = bareetraxfs_init,
diff --git a/hw/gumstix.c b/hw/gumstix.c
index ee63f63..8eca2ba 100644
--- a/hw/gumstix.c
+++ b/hw/gumstix.c
@@ -120,13 +120,13 @@ static void verdex_init(ram_addr_t ram_size,
 qdev_get_gpio_in(cpu-gpio, 99));
 }
 
-static QEMUMachine connex_machine = {
+static const QEMUMachine connex_machine = {
 .name = connex,
 .desc = Gumstix Connex (PXA255),
 .init = connex_init,
 };
 
-static QEMUMachine verdex_machine = {
+static const QEMUMachine verdex_machine = {
 .name = verdex,
 .desc = Gumstix Verdex (PXA270),
 .init = verdex_init,
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index ccc44db..a7d02ba 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -512,7 +512,7 @@ static void integratorcp_init(ram_addr_t ram_size,
 arm_load_kernel(env, integrator_binfo);
 }
 
-static QEMUMachine integratorcp_machine = {
+static const QEMUMachine integratorcp_machine = {
 .name = integratorcp,
 .desc = ARM Integrator/CP (ARM926EJ-S),
 .init = integratorcp_init,
diff --git a/hw/leon3.c b/hw/leon3.c
index 919f49f..b6ebf52 100644
--- a/hw/leon3.c
+++ b/hw/leon3.c
@@ -202,7 +202,7 @@ static void leon3_generic_hw_init(ram_addr_t  ram_size,
 }
 }
 
-QEMUMachine leon3_generic_machine = 

[Qemu-devel] [PATCH v3 2/7] hw: Add maximum RAM specifications for ARM devboard models

2011-03-29 Thread Peter Maydell
Specify the maximum memory permitted for the various ARM devboard
models (integratorcp, realview-eb, realview-eb-mpcore, realview-pb-a8,
realview-pbx-a9, versatilepb, versatileab). This means we now handle
attempts to specify too much RAM gracefully rather than causing
the guest to crash in an obscure fashion.

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
 hw/integratorcp.c |1 +
 hw/realview.c |   11 +++
 hw/versatilepb.c  |5 +
 3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index b049940..ccc44db 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -516,6 +516,7 @@ static QEMUMachine integratorcp_machine = {
 .name = integratorcp,
 .desc = ARM Integrator/CP (ARM926EJ-S),
 .init = integratorcp_init,
+.max_ram = 256 * 1024 * 1024,
 .is_default = 1,
 };
 
diff --git a/hw/realview.c b/hw/realview.c
index a67861e..a158ade 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -432,6 +432,7 @@ static QEMUMachine realview_eb_machine = {
 .desc = ARM RealView Emulation Baseboard (ARM926EJ-S),
 .init = realview_eb_init,
 .use_scsi = 1,
+.max_ram = 256 * 1024 * 1024,
 };
 
 static QEMUMachine realview_eb_mpcore_machine = {
@@ -440,12 +441,18 @@ static QEMUMachine realview_eb_mpcore_machine = {
 .init = realview_eb_mpcore_init,
 .use_scsi = 1,
 .max_cpus = 4,
+.max_ram = 256 * 1024 * 1024,
 };
 
 static QEMUMachine realview_pb_a8_machine = {
 .name = realview-pb-a8,
 .desc = ARM RealView Platform Baseboard for Cortex-A8,
 .init = realview_pb_a8_init,
+/* The PB-A8 has 512MB; qemu also supports an extra PBX-A9-like
+ * 512MB although strictly speaking that area of the address
+ * space is 'reserved' on the PB-A8.
+ */
+.max_ram = 1024 * 1024 * 1024,
 };
 
 static QEMUMachine realview_pbx_a9_machine = {
@@ -454,6 +461,10 @@ static QEMUMachine realview_pbx_a9_machine = {
 .init = realview_pbx_a9_init,
 .use_scsi = 1,
 .max_cpus = 4,
+/* Realview PBX has 1GB of RAM (512MB on the motherboard
+ * and another 512MB on the daughterboard)
+ */
+.max_ram = 1024 * 1024 * 1024,
 };
 
 static void realview_machine_init(void)
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 9f1bfcf..aeddd28 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -329,6 +329,10 @@ static QEMUMachine versatilepb_machine = {
 .desc = ARM Versatile/PB (ARM926EJ-S),
 .init = vpb_init,
 .use_scsi = 1,
+/* Hardware allows for up to 512MB expansion memory in two
+ * non-contiguous sections, but we only support up to 256MB
+ */
+.max_ram = 256 * 1024 * 1024,
 };
 
 static QEMUMachine versatileab_machine = {
@@ -336,6 +340,7 @@ static QEMUMachine versatileab_machine = {
 .desc = ARM Versatile/AB (ARM926EJ-S),
 .init = vab_init,
 .use_scsi = 1,
+.max_ram = 256 * 1024 * 1024,
 };
 
 static void versatile_machine_init(void)
-- 
1.7.1




[Qemu-devel] [PATCH v3 5/7] hw/sun4m: Use the QEMUMachine max_ram to implement memory limit

2011-03-29 Thread Peter Maydell
Use the max_ram field in QEMUMachine to indicate maximum memory,
rather than a field in the sun4*_hwdef structure. This allows us
to use the vl.c check on RAM specifications rather than having to
code our own.

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
 hw/sun4m.c |   42 --
 1 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/hw/sun4m.c b/hw/sun4m.c
index bd9ef91..2ae8c45 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -102,7 +102,6 @@ struct sun4m_hwdef {
 uint8_t nvram_machine_id;
 uint16_t machine_id;
 uint32_t iommu_version;
-uint64_t max_mem;
 const char * const default_cpu_model;
 };
 
@@ -120,7 +119,6 @@ struct sun4d_hwdef {
 uint8_t nvram_machine_id;
 uint16_t machine_id;
 uint32_t iounit_version;
-uint64_t max_mem;
 const char * const default_cpu_model;
 };
 
@@ -134,7 +132,6 @@ struct sun4c_hwdef {
 uint8_t nvram_machine_id;
 uint16_t machine_id;
 uint32_t iommu_version;
-uint64_t max_mem;
 const char * const default_cpu_model;
 };
 
@@ -746,13 +743,6 @@ static void ram_init(target_phys_addr_t addr, ram_addr_t 
RAM_size,
 RamDevice *d;
 
 /* allocate RAM */
-if ((uint64_t)RAM_size  max_mem) {
-fprintf(stderr,
-qemu: Too much memory for this machine: %d, maximum %d\n,
-(unsigned int)(RAM_size / (1024 * 1024)),
-(unsigned int)(max_mem / (1024 * 1024)));
-exit(1);
-}
 dev = qdev_create(NULL, memory);
 s = sysbus_from_qdev(dev);
 
@@ -833,10 +823,10 @@ static void sun4m_hw_init(const struct sun4m_hwdef 
*hwdef, ram_addr_t RAM_size,
 
 
 /* set up devices */
-ram_init(0, RAM_size, hwdef-max_mem);
+ram_init(0, RAM_size, hwdef-machine.max_ram);
 /* models without ECC don't trap when missing ram is accessed */
 if (!hwdef-ecc_base) {
-empty_slot_init(RAM_size, hwdef-max_mem - RAM_size);
+empty_slot_init(RAM_size, hwdef-machine.max_ram - RAM_size);
 }
 
 prom_init(hwdef-slavio_base, bios_name);
@@ -1110,6 +1100,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
 .desc = Sun4m platform, SPARCstation 5,
 .init = ss5_init,
 .use_scsi = 1,
+.max_ram = 0x1000,
 .is_default = 1,
 },
 .iommu_base   = 0x1000,
@@ -1135,7 +1126,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
 .nvram_machine_id = 0x80,
 .machine_id = ss5_id,
 .iommu_version = 0x0500,
-.max_mem = 0x1000,
 .default_cpu_model = Fujitsu MB86904,
 },
 /* SS-10 */
@@ -1146,6 +1136,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
 .init = ss10_init,
 .use_scsi = 1,
 .max_cpus = 4,
+.max_ram = 0xfULL,
 },
 .iommu_base   = 0xfe000ULL,
 .tcx_base = 0xe2000ULL,
@@ -1168,7 +1159,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
 .nvram_machine_id = 0x72,
 .machine_id = ss10_id,
 .iommu_version = 0x0300,
-.max_mem = 0xfULL,
 .default_cpu_model = TI SuperSparc II,
 },
 /* SS-600MP */
@@ -1179,6 +1169,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
 .init = ss600mp_init,
 .use_scsi = 1,
 .max_cpus = 4,
+.max_ram = 0xfULL,
 },
 .iommu_base   = 0xfe000ULL,
 .tcx_base = 0xe2000ULL,
@@ -1199,7 +1190,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
 .nvram_machine_id = 0x71,
 .machine_id = ss600mp_id,
 .iommu_version = 0x0100,
-.max_mem = 0xfULL,
 .default_cpu_model = TI SuperSparc II,
 },
 /* SS-20 */
@@ -1210,6 +1200,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
 .init = ss20_init,
 .use_scsi = 1,
 .max_cpus = 4,
+.max_ram = 0xfULL,
 },
 .iommu_base   = 0xfe000ULL,
 .tcx_base = 0xe2000ULL,
@@ -1248,7 +1239,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
 .nvram_machine_id = 0x72,
 .machine_id = ss20_id,
 .iommu_version = 0x1300,
-.max_mem = 0xfULL,
 .default_cpu_model = TI SuperSparc II,
 },
 /* Voyager */
@@ -1258,6 +1248,7 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
 .desc = Sun4m platform, SPARCstation Voyager,
 .init = vger_init,
 .use_scsi = 1,
+.max_ram = 0x1000,
 },
 .iommu_base   = 0x1000,
 .tcx_base = 0x5000,
@@ -1278,7 +1269,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
 .nvram_machine_id = 0x80,
 .machine_id = vger_id,
 .iommu_version = 0x0500,
-.max_mem = 0x1000,
 .default_cpu_model = Fujitsu MB86904,
 

[Qemu-devel] [PATCH v3 0/7] Let boards state maximum RAM limits in QEMUMachine struct

2011-03-29 Thread Peter Maydell
This primary aim of this patchset is to add a new 'max_ram' field to the
QEMUMachine structure so that a board model can specify the maximum RAM it
will accept.  We can then produce a friendly diagnostic message when the
user tries to start qemu with a '-m' option asking for more RAM than that. 
(Currently most of the ARM devboard models respond with an obscure guest
crash when the guest tries to access RAM and finds device registers
instead.)

If no maximum size is specified we default to the old behaviour of
do not impose any limit.

The bulk of the patchset is knock-on cleanup as a result, in particular
allowing QEMUMachine structs to be const and sun4m cleanup.

Changes in v3:
 * as suggested by Blue Swirl, new patch 3 to make qemu_register_machine
   take a const QEMUMachine * rather than a non-const one
 * this makes the sun4m patch (old 3, new 4) simpler as we don't have to
   move 'const' qualifiers around
 * new patch 7 which adds 'const' to all the board QEMUMachine definitions

Changes in v2:
 * use target_physaddr_t rather than ram_addr_t for max_ram, so
   we can specify maximum ram sizes for 64 bit target boards
 * new patches 3,4 which update sun4m to use the generic max_ram, so
   we can delete the sun4m-specific code which was doing the same job
 * patch 5 does some tidy-up of sun4m init functions; not strictly
   related but the assert() at least is enabled by the cleanup done
   in patch 3.


Peter Maydell (7):
  Allow boards to specify maximum RAM size
  hw: Add maximum RAM specifications for ARM devboard models
  vl.c: Fix machine registration so QEMUMachine structs can be const
  hw/sun4m: Move QEMUMachine structs into sun4*_hwdef structs
  hw/sun4m: Use the QEMUMachine max_ram to implement memory limit
  hw/sun4m: Use a macro to hide the repetitive board init functions
  hw: Make QEMUMachine structure definitions const

 hw/an5206.c   |2 +-
 hw/axis_dev88.c   |2 +-
 hw/boards.h   |6 +-
 hw/dummy_m68k.c   |2 +-
 hw/etraxfs.c  |2 +-
 hw/gumstix.c  |4 +-
 hw/integratorcp.c |3 +-
 hw/leon3.c|2 +-
 hw/lm32_boards.c  |4 +-
 hw/mainstone.c|2 +-
 hw/mcf5208.c  |2 +-
 hw/mips_fulong2e.c|2 +-
 hw/mips_jazz.c|4 +-
 hw/mips_malta.c   |2 +-
 hw/mips_mipssim.c |2 +-
 hw/mips_r4k.c |2 +-
 hw/musicpal.c |2 +-
 hw/nseries.c  |4 +-
 hw/omap_sx1.c |4 +-
 hw/palm.c |2 +-
 hw/pc_piix.c  |   12 +-
 hw/petalogix_ml605_mmu.c  |2 +-
 hw/petalogix_s3adsp1800_mmu.c |2 +-
 hw/ppc405_boards.c|4 +-
 hw/ppc440_bamboo.c|4 +-
 hw/ppc_newworld.c |2 +-
 hw/ppc_oldworld.c |2 +-
 hw/ppc_prep.c |2 +-
 hw/ppce500_mpc8544ds.c|2 +-
 hw/r2d.c  |2 +-
 hw/realview.c |   19 ++-
 hw/s390-virtio.c  |2 +-
 hw/shix.c |2 +-
 hw/spitz.c|8 +-
 hw/stellaris.c|4 +-
 hw/sun4m.c|  523 -
 hw/sun4u.c|6 +-
 hw/syborg.c   |2 +-
 hw/tosa.c |2 +-
 hw/versatilepb.c  |9 +-
 hw/virtex_ml507.c |2 +-
 hw/xen_machine_pv.c   |2 +-
 vl.c  |  115 ++
 43 files changed, 363 insertions(+), 422 deletions(-)




[Qemu-devel] [PATCH v3 4/7] hw/sun4m: Move QEMUMachine structs into sun4*_hwdef structs

2011-03-29 Thread Peter Maydell
Combine the per-machine QEMUMachine struct into the per-machine
sun4*_hwdef struct. This requires some moving around of init functions
to avoid forward references.

The motivation is to allow the init functions to get at the
QEMUMachine struct for the board, so we can use its max_ram field
rather than having a max_mem field in the sun4*_hwdef struct.

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
 hw/sun4m.c |  527 ++--
 1 files changed, 262 insertions(+), 265 deletions(-)

diff --git a/hw/sun4m.c b/hw/sun4m.c
index df3aa32..bd9ef91 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -87,6 +87,7 @@
 #define ESCC_CLOCK 4915200
 
 struct sun4m_hwdef {
+QEMUMachine machine;
 target_phys_addr_t iommu_base, iommu_pad_base, iommu_pad_len, slavio_base;
 target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base;
 target_phys_addr_t serial_base, fd_base;
@@ -108,6 +109,7 @@ struct sun4m_hwdef {
 #define MAX_IOUNITS 5
 
 struct sun4d_hwdef {
+QEMUMachine machine;
 target_phys_addr_t iounit_bases[MAX_IOUNITS], slavio_base;
 target_phys_addr_t counter_base, nvram_base, ms_kb_base;
 target_phys_addr_t serial_base;
@@ -123,6 +125,7 @@ struct sun4d_hwdef {
 };
 
 struct sun4c_hwdef {
+QEMUMachine machine;
 target_phys_addr_t iommu_base, slavio_base;
 target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base;
 target_phys_addr_t serial_base, fd_base;
@@ -1006,9 +1009,109 @@ enum {
 ss2000_id,
 };
 
+static const struct sun4m_hwdef sun4m_hwdefs[];
+
+/* SPARCstation 5 hardware initialisation */
+static void ss5_init(ram_addr_t RAM_size,
+ const char *boot_device,
+ const char *kernel_filename, const char *kernel_cmdline,
+ const char *initrd_filename, const char *cpu_model)
+{
+sun4m_hw_init(sun4m_hwdefs[0], RAM_size, boot_device, kernel_filename,
+  kernel_cmdline, initrd_filename, cpu_model);
+}
+
+/* SPARCstation 10 hardware initialisation */
+static void ss10_init(ram_addr_t RAM_size,
+  const char *boot_device,
+  const char *kernel_filename, const char *kernel_cmdline,
+  const char *initrd_filename, const char *cpu_model)
+{
+sun4m_hw_init(sun4m_hwdefs[1], RAM_size, boot_device, kernel_filename,
+  kernel_cmdline, initrd_filename, cpu_model);
+}
+
+/* SPARCserver 600MP hardware initialisation */
+static void ss600mp_init(ram_addr_t RAM_size,
+ const char *boot_device,
+ const char *kernel_filename,
+ const char *kernel_cmdline,
+ const char *initrd_filename, const char *cpu_model)
+{
+sun4m_hw_init(sun4m_hwdefs[2], RAM_size, boot_device, kernel_filename,
+  kernel_cmdline, initrd_filename, cpu_model);
+}
+
+/* SPARCstation 20 hardware initialisation */
+static void ss20_init(ram_addr_t RAM_size,
+  const char *boot_device,
+  const char *kernel_filename, const char *kernel_cmdline,
+  const char *initrd_filename, const char *cpu_model)
+{
+sun4m_hw_init(sun4m_hwdefs[3], RAM_size, boot_device, kernel_filename,
+  kernel_cmdline, initrd_filename, cpu_model);
+}
+
+/* SPARCstation Voyager hardware initialisation */
+static void vger_init(ram_addr_t RAM_size,
+  const char *boot_device,
+  const char *kernel_filename, const char *kernel_cmdline,
+  const char *initrd_filename, const char *cpu_model)
+{
+sun4m_hw_init(sun4m_hwdefs[4], RAM_size, boot_device, kernel_filename,
+  kernel_cmdline, initrd_filename, cpu_model);
+}
+
+/* SPARCstation LX hardware initialisation */
+static void ss_lx_init(ram_addr_t RAM_size,
+   const char *boot_device,
+   const char *kernel_filename, const char *kernel_cmdline,
+   const char *initrd_filename, const char *cpu_model)
+{
+sun4m_hw_init(sun4m_hwdefs[5], RAM_size, boot_device, kernel_filename,
+  kernel_cmdline, initrd_filename, cpu_model);
+}
+
+/* SPARCstation 4 hardware initialisation */
+static void ss4_init(ram_addr_t RAM_size,
+ const char *boot_device,
+ const char *kernel_filename, const char *kernel_cmdline,
+ const char *initrd_filename, const char *cpu_model)
+{
+sun4m_hw_init(sun4m_hwdefs[6], RAM_size, boot_device, kernel_filename,
+  kernel_cmdline, initrd_filename, cpu_model);
+}
+
+/* SPARCClassic hardware initialisation */
+static void scls_init(ram_addr_t RAM_size,
+  const char *boot_device,
+  const char *kernel_filename, const char *kernel_cmdline,
+  const char *initrd_filename, const 

[Qemu-devel] Re: KVM call agenda for Mars 29th

2011-03-29 Thread Juan Quintela
Juan Quintela quint...@redhat.com wrote:
 Please, send in any agenda items you are interested in covering.

 Later, Juan.

As there is no topic for the agenda (I asked for topics too late), call
is canceled.

Later, Juan.



[Qemu-devel] [PATCH v3 6/7] hw/sun4m: Use a macro to hide the repetitive board init functions

2011-03-29 Thread Peter Maydell
Tidy up the repetitive board init functions (which are all the same
apart from which hwdef struct they pass in). This also lets us add
an assertion that the hwdef points to the init function which uses
that hwdef, rather than some other one.

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
 hw/sun4m.c |  138 ++--
 1 files changed, 22 insertions(+), 116 deletions(-)

diff --git a/hw/sun4m.c b/hw/sun4m.c
index 2ae8c45..f130fc9 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -1001,96 +1001,27 @@ enum {
 
 static const struct sun4m_hwdef sun4m_hwdefs[];
 
-/* SPARCstation 5 hardware initialisation */
-static void ss5_init(ram_addr_t RAM_size,
- const char *boot_device,
- const char *kernel_filename, const char *kernel_cmdline,
- const char *initrd_filename, const char *cpu_model)
-{
-sun4m_hw_init(sun4m_hwdefs[0], RAM_size, boot_device, kernel_filename,
-  kernel_cmdline, initrd_filename, cpu_model);
-}
-
-/* SPARCstation 10 hardware initialisation */
-static void ss10_init(ram_addr_t RAM_size,
-  const char *boot_device,
-  const char *kernel_filename, const char *kernel_cmdline,
-  const char *initrd_filename, const char *cpu_model)
-{
-sun4m_hw_init(sun4m_hwdefs[1], RAM_size, boot_device, kernel_filename,
-  kernel_cmdline, initrd_filename, cpu_model);
-}
-
-/* SPARCserver 600MP hardware initialisation */
-static void ss600mp_init(ram_addr_t RAM_size,
- const char *boot_device,
- const char *kernel_filename,
- const char *kernel_cmdline,
- const char *initrd_filename, const char *cpu_model)
-{
-sun4m_hw_init(sun4m_hwdefs[2], RAM_size, boot_device, kernel_filename,
-  kernel_cmdline, initrd_filename, cpu_model);
-}
-
-/* SPARCstation 20 hardware initialisation */
-static void ss20_init(ram_addr_t RAM_size,
-  const char *boot_device,
-  const char *kernel_filename, const char *kernel_cmdline,
-  const char *initrd_filename, const char *cpu_model)
-{
-sun4m_hw_init(sun4m_hwdefs[3], RAM_size, boot_device, kernel_filename,
-  kernel_cmdline, initrd_filename, cpu_model);
-}
-
-/* SPARCstation Voyager hardware initialisation */
-static void vger_init(ram_addr_t RAM_size,
-  const char *boot_device,
-  const char *kernel_filename, const char *kernel_cmdline,
-  const char *initrd_filename, const char *cpu_model)
-{
-sun4m_hw_init(sun4m_hwdefs[4], RAM_size, boot_device, kernel_filename,
-  kernel_cmdline, initrd_filename, cpu_model);
+#define SUN4_INITFN(NAME, SUBARCH, OFFSET) \
+static void NAME##_init(ram_addr_t RAM_size, \
+ const char *boot_device, \
+ const char *kernel_filename, const char *kernel_cmdline, \
+ const char *initrd_filename, const char *cpu_model) \
+{ \
+assert(SUBARCH##_hwdefs[OFFSET].machine.init == NAME##_init);   \
+SUBARCH##_hw_init(SUBARCH##_hwdefs[OFFSET], RAM_size, boot_device, \
+  kernel_filename, kernel_cmdline, initrd_filename, \
+  cpu_model); \
 }
 
-/* SPARCstation LX hardware initialisation */
-static void ss_lx_init(ram_addr_t RAM_size,
-   const char *boot_device,
-   const char *kernel_filename, const char *kernel_cmdline,
-   const char *initrd_filename, const char *cpu_model)
-{
-sun4m_hw_init(sun4m_hwdefs[5], RAM_size, boot_device, kernel_filename,
-  kernel_cmdline, initrd_filename, cpu_model);
-}
-
-/* SPARCstation 4 hardware initialisation */
-static void ss4_init(ram_addr_t RAM_size,
- const char *boot_device,
- const char *kernel_filename, const char *kernel_cmdline,
- const char *initrd_filename, const char *cpu_model)
-{
-sun4m_hw_init(sun4m_hwdefs[6], RAM_size, boot_device, kernel_filename,
-  kernel_cmdline, initrd_filename, cpu_model);
-}
-
-/* SPARCClassic hardware initialisation */
-static void scls_init(ram_addr_t RAM_size,
-  const char *boot_device,
-  const char *kernel_filename, const char *kernel_cmdline,
-  const char *initrd_filename, const char *cpu_model)
-{
-sun4m_hw_init(sun4m_hwdefs[7], RAM_size, boot_device, kernel_filename,
-  kernel_cmdline, initrd_filename, cpu_model);
-}
-
-/* SPARCbook hardware initialisation */
-static void sbook_init(ram_addr_t RAM_size,
-   const char *boot_device,
-   const char *kernel_filename, const char *kernel_cmdline,
-   

[Qemu-devel] Re: [PATCH 04/19] s390x: fix s390-virtio-serial

2011-03-29 Thread Amit Shah
On (Tue) 29 Mar 2011 [15:29:31], Alexander Graf wrote:
 Commit 6b331efb733a0f913ddc0b7762a1307dec304061 broke the s390 proxy version
 of virtio-serial by only taking its PCI brother into account.
 
 So let's adjust s390-virtio-serial the same way as its PCI counterpart, making
 it compile and work again.

Ouch, sorry for that!

Amit



Re: [Qemu-devel] [PATCH v3] Do not delete BlockDriverState when deleting the drive

2011-03-29 Thread Ryan Harper
* Markus Armbruster arm...@redhat.com [2011-03-29 02:44]:
 Ryan Harper ry...@us.ibm.com writes:
 
  When removing a drive from the host-side via drive_del we currently have the
  following path:
 
  drive_del
  qemu_aio_flush()
  bdrv_close()// zaps bs-drv, which makes any subsequent I/O get
  // dropped.  Works as designed
  drive_uninit()
  bdrv_delete()   // frees the bs.  Since the device is still connected to
  // bs, any subsequent I/O is a use-after-free.
 
  The value of bs-drv becomes unpredictable on free.  As long as it
  remains null, I/O still gets dropped, however it could become non-null at 
  any
  point after the free resulting SEGVs or other QEMU state corruption.
 
  To resolve this issue as simply as possible, we can chose to not actually
  delete the BlockDriverState pointer.  Since bdrv_close() handles setting 
  the drv
  pointer to NULL, we just need to remove the BlockDriverState from the QLIST
  that is used to enumerate the block devices.  This is currently handled 
  within
  bdrv_delete, so move this into its own function, bdrv_make_anon().
 
  The result is that we can now invoke drive_del, this closes the file 
  descriptors
  and sets BlockDriverState-drv to NULL which prevents futher IO to the 
  device,
  and since we do not free BlockDriverState, we don't have to worry about the 
  copy
  retained in the block devices.
 
  We also don't attempt to remove the qdev property since we are no longer 
  deleting
  the BlockDriverState on drives with associated drives.  This also allows for
  removing Drives with no devices associated either.
 
  Reported-by: Markus Armbruster arm...@redhat.com
  Signed-off-by: Ryan Harper ry...@us.ibm.com
  ---
  v2-v3
   - Update drive_del use after free description
   - s/bdrv_remove/bdrv_make_anon/g
   - Don't remove qdev property since we don't delete bs any more
   - If (bs-peer) bdrv_make_anon else bdrv_delete to handle removing
 drives with no device.
  v1-v2
- NULL bs-device_name after removing from list to prevent
  second removal.
 
   block.c|   13 ++---
   block.h|1 +
   blockdev.c |   25 -
   3 files changed, 19 insertions(+), 20 deletions(-)
 
  diff --git a/block.c b/block.c
  index c8e2f97..6a5d3f2 100644
  --- a/block.c
  +++ b/block.c
  @@ -697,14 +697,21 @@ void bdrv_close_all(void)
   }
   }
   
  +/* make a BlockDriverState anonymous by removing from bdrv_state list.
  +   Also, NULL terminate the device_name to prevent double remove */
  +void bdrv_make_anon(BlockDriverState *bs)
  +{
  +if (bs-device_name[0] != '\0') {
  +QTAILQ_REMOVE(bdrv_states, bs, list);
  +}
 
 You lost
 
 +bs-device_name[0] = '\0';
 
 since v2.  Oops.

Crap.  

 
  +}
  +
   void bdrv_delete(BlockDriverState *bs)
   {
   assert(!bs-peer);
   
   /* remove from list, if necessary */
  -if (bs-device_name[0] != '\0') {
  -QTAILQ_REMOVE(bdrv_states, bs, list);
  -}
  +bdrv_make_anon(bs);
   
   bdrv_close(bs);
   if (bs-file != NULL) {
  diff --git a/block.h b/block.h
  index 5d78fc0..52e9cad 100644
  --- a/block.h
  +++ b/block.h
  @@ -66,6 +66,7 @@ int bdrv_create(BlockDriver *drv, const char* filename,
   QEMUOptionParameter *options);
   int bdrv_create_file(const char* filename, QEMUOptionParameter *options);
   BlockDriverState *bdrv_new(const char *device_name);
  +void bdrv_make_anon(BlockDriverState *bs);
   void bdrv_delete(BlockDriverState *bs);
   int bdrv_file_open(BlockDriverState **pbs, const char *filename, int 
  flags);
   int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
  diff --git a/blockdev.c b/blockdev.c
  index ecf2252..2c0eb06 100644
  --- a/blockdev.c
  +++ b/blockdev.c
  @@ -737,8 +737,6 @@ int do_drive_del(Monitor *mon, const QDict *qdict, 
  QObject **ret_data)
   {
   const char *id = qdict_get_str(qdict, id);
   BlockDriverState *bs;
  -BlockDriverState **ptr;
  -Property *prop;
   
   bs = bdrv_find(id);
   if (!bs) {
  @@ -755,24 +753,17 @@ int do_drive_del(Monitor *mon, const QDict *qdict, 
  QObject **ret_data)
   bdrv_flush(bs);
   bdrv_close(bs);
   
  -/* clean up guest state from pointing to host resource by
  - * finding and removing DeviceState drive property */
  +/* if we have a device associated with this BlockDriverState (bs-peer)
  + * then we need to make the drive anonymous until the device
  + * can be removed.  If this is a drive with no device backing
  + * then we can just get rid of the block driver state right here.
  + */
   if (bs-peer) {
  -for (prop = bs-peer-info-props; prop  prop-name; prop++) {
  -if (prop-info-type == PROP_TYPE_DRIVE) {
  -ptr = qdev_get_prop_ptr(bs-peer, prop);
  -if (*ptr == bs) {
  -bdrv_detach(bs, bs-peer);
  -*ptr = NULL;
  -  

Re: [Qemu-devel] [PATCH v3] Do not delete BlockDriverState when deleting the drive

2011-03-29 Thread Ryan Harper
* Markus Armbruster arm...@redhat.com [2011-03-29 04:06]:
 Since you have to respin anyway, would you mind limiting commit message
 line length to 70-75 characters?  Thanks.

yep


-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ry...@us.ibm.com



[Qemu-devel] [PATCH] virtio-serial-bus: use bh for unthrottling

2011-03-29 Thread Alon Levy
Instead of calling flush_queued_data when unthrottling, schedule
a bh. That way we can return immediately to the caller, and the
flush uses the same call path as a have_data for callbackee.

migration: since version 2 of the migration protocol we unthrottle
if there is data. So we don't need to add anything special here, just
the unthrottling mechanism changed, from directl function call to bh.
---
 hw/virtio-serial-bus.c |   11 +--
 hw/virtio-serial.h |5 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index a82fbe9..e8a892d 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -285,6 +285,13 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port)
 return 0;
 }
 
+static void bh_virtio_serial_flush_queued_data(void *opaque)
+{
+VirtIOSerialPort *port = opaque;
+
+flush_queued_data(port);
+}
+
 void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle)
 {
 if (!port) {
@@ -295,8 +302,7 @@ void virtio_serial_throttle_port(VirtIOSerialPort *port, 
bool throttle)
 if (throttle) {
 return;
 }
-
-flush_queued_data(port);
+qemu_bh_schedule(port-bh);
 }
 
 /* Guest wants to notify us of some event */
@@ -721,6 +727,7 @@ static int virtser_port_qdev_init(DeviceState *qdev, 
DeviceInfo *base)
 bool plugging_port0;
 
 port-vser = bus-vser;
+port-bh = qemu_bh_new(bh_virtio_serial_flush_queued_data, port);
 
 /*
  * Is the first console port we're seeing? If so, put it up at
diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
index 5eb948e..0fa03d1 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -119,6 +119,11 @@ struct VirtIOSerialPort {
 uint32_t iov_idx;
 uint64_t iov_offset;
 
+/*
+ * When unthrottling we use a buttomhalf to call flush_queued_data.
+ */
+QEMUBH *bh;
+
 /* Identify if this is a port that binds with hvc in the guest */
 uint8_t is_console;
 
-- 
1.7.4.1




[Qemu-devel] Re: [PATCH 16/19] s390x: Implement opcode helpers

2011-03-29 Thread Richard Henderson
On 03/29/2011 06:29 AM, Alexander Graf wrote:
 +if (src == dest) {
 +memset((void*)dest, 0, l + 1);
 +return 0;
 +}

This should be g2h(dest), surely.


r~



[Qemu-devel] Re: [PATCH 16/19] s390x: Implement opcode helpers

2011-03-29 Thread Alexander Graf

On 03/29/2011 06:13 PM, Richard Henderson wrote:

On 03/29/2011 06:29 AM, Alexander Graf wrote:

+if (src == dest) {
+memset((void*)dest, 0, l + 1);
+return 0;
+}

This should be g2h(dest), surely.


Ah, nice. Didn't know about that one :). Very useful indeed.


Alex




Re: [Qemu-devel] [PATCH 1/3] arm: basic support for ARMv4/ARMv4T emulation

2011-03-29 Thread Dmitry Eremin-Solenikov
Hello,

On 3/27/11, Peter Maydell peter.mayd...@linaro.org wrote:
 I've just gone through this distinguishing v5 sublevels.
 I've also gone back and looked up an older ARM ARM for any v5 vs
 v5T differences, and it looks like the only difference really is
 whether Thumb mode works: the ARM instruction set is exactly the
 same including the existence of BX/BLX.

Will submit the updated patchet in a few minutes.

BTW: do you know any real core which used ARMv5/ARMv5T and
not ARMv5TE (I've failed to find such one. Maybe I should check older revisions
of datasheets: at least 946r0 was ARMv5TExP and r1p1 is ARM9E-S-based and
so full ARMv5TE).

-- 
With best wishes
Dmitry



[Qemu-devel] [PATCH 2/3] Implement basic part of SA-1110/SA-1100

2011-03-29 Thread Dmitry Eremin-Solenikov
Basic implementation of DEC/Intel SA-1100/SA-1110 chips emulation.
Implemented:
 - IRQs
 - GPIO
 - PPC
 - RTC
 - UARTs (no IrDA/etc.)
 - OST reused from pxa25x

Everything else is TODO (esp. PM/idle/sleep!) - see the todo in the
hw/strongarm.c

V2:
  * removed all strongarm variants except latest
  * dropped unused casts
  * fixed PIC vmstate
  * fixed new devices created with version_id = 1

Signed-off-by: Dmitry Eremin-Solenikov dbarysh...@gmail.com
---
 Makefile.target |1 +
 hw/strongarm.c  | 1301 +++
 hw/strongarm.h  |   62 +++
 target-arm/cpu.h|3 +
 target-arm/helper.c |9 +
 5 files changed, 1376 insertions(+), 0 deletions(-)
 create mode 100644 hw/strongarm.c
 create mode 100644 hw/strongarm.h

diff --git a/Makefile.target b/Makefile.target
index 62b102a..d071a4d 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -328,6 +328,7 @@ obj-arm-y += framebuffer.o
 obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
 obj-arm-y += syborg_serial.o syborg_timer.o syborg_pointer.o syborg_rtc.o
 obj-arm-y += syborg_virtio.o
+obj-arm-y += strongarm.o
 
 obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
 obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o
diff --git a/hw/strongarm.c b/hw/strongarm.c
new file mode 100644
index 000..9f3df87
--- /dev/null
+++ b/hw/strongarm.c
@@ -0,0 +1,1301 @@
+/*
+ * StrongARM SA-1100/SA-1110 emulation
+ *
+ * Copyright (C) 2011 Dmitry Eremin-Solenikov
+ *
+ * Largely based on StrongARM emulation:
+ * Copyright (c) 2006 Openedhand Ltd.
+ * Written by Andrzej Zaborowski bal...@zabor.org
+ *
+ * UART code based on QEMU 16550A UART emulation
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ * Copyright (c) 2008 Citrix Systems, Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+#include sysbus.h
+#include strongarm.h
+#include qemu-error.h
+#include arm-misc.h
+#include sysemu.h
+
+/*
+ TODO
+ - Implement cp15, c14 ?
+ - Implement cp15, c15 !!! (idle used in L)
+ - Implement idle mode handling/DIM
+ - Implement sleep mode/Wake sources
+ - Implement reset control
+ - Implement memory control regs
+ - PCMCIA handling
+ - Maybe support MBGNT/MBREQ
+ - DMA channels
+ - GPCLK
+ - IrDA
+ - MCP
+ - Enhance UART with modem signals
+ */
+
+static struct {
+target_phys_addr_t io_base;
+int irq;
+} sa_serial[] = {
+{ 0x8001, SA_PIC_UART1 },
+{ 0x8003, SA_PIC_UART2 },
+{ 0x8005, SA_PIC_UART3 },
+{ 0, 0 }
+};
+
+/* Interrupt Controller */
+typedef struct {
+SysBusDevice busdev;
+qemu_irqirq;
+qemu_irqfiq;
+
+uint32_t pending;
+uint32_t enabled;
+uint32_t is_fiq;
+uint32_t int_idle;
+} StrongARMPICState;
+
+#define ICIP0x00
+#define ICMR0x04
+#define ICLR0x08
+#define ICFP0x10
+#define ICPR0x20
+#define ICCR0x0c
+
+#define SA_PIC_SRCS 32
+
+
+static void strongarm_pic_update(void *opaque)
+{
+StrongARMPICState *s = opaque;
+
+/* FIXME: reflect DIM */
+qemu_set_irq(s-fiq, s-pending  s-enabled   s-is_fiq);
+qemu_set_irq(s-irq, s-pending  s-enabled  ~s-is_fiq);
+}
+
+static void strongarm_pic_set_irq(void *opaque, int irq, int level)
+{
+StrongARMPICState *s = opaque;
+
+if (level) {
+s-pending |= 1  irq;
+} else {
+s-pending = ~(1  irq);
+}
+
+strongarm_pic_update(s);
+}
+
+static uint32_t strongarm_pic_mem_read(void *opaque, target_phys_addr_t offset)
+{
+StrongARMPICState *s = opaque;
+
+switch (offset) {
+case ICIP:
+return s-pending  ~s-is_fiq  s-enabled;
+case ICMR:
+return s-enabled;
+case ICLR:
+return s-is_fiq;
+case ICCR:
+return s-int_idle == 0;
+case ICFP:
+return s-pending  s-is_fiq  s-enabled;
+case ICPR:
+return s-pending;
+default:
+printf(%s: Bad register offset 0x TARGET_FMT_plx \n,
+__func__, offset);
+return 0;
+}
+}
+
+static void strongarm_pic_mem_write(void *opaque, target_phys_addr_t offset,
+uint32_t value)
+{
+StrongARMPICState *s = opaque;
+
+switch (offset) {
+case ICMR:
+s-enabled = value;
+break;
+case ICLR:
+s-is_fiq = value;
+break;
+case ICCR:
+s-int_idle = (value  1) ? 0 : ~0;
+break;
+default:
+printf(%s: Bad register offset 0x TARGET_FMT_plx \n,
+__func__, offset);
+break;
+}
+strongarm_pic_update(s);
+}
+
+static CPUReadMemoryFunc * const strongarm_pic_readfn[] = {
+strongarm_pic_mem_read,
+strongarm_pic_mem_read,
+strongarm_pic_mem_read,
+};
+
+static CPUWriteMemoryFunc * const strongarm_pic_writefn[] = {
+strongarm_pic_mem_write,
+strongarm_pic_mem_write,
+strongarm_pic_mem_write,
+};
+
+static int 

[Qemu-devel] [PATCH 3/3] Basic implementation of Sharp Zaurus SL-5500 collie PDA

2011-03-29 Thread Dmitry Eremin-Solenikov
Add very basic implementation of collie PDA emulation. The system lacks
LoCoMo and graphics/sound emulation. Linux kernel boots up to mounting
rootfs (theoretically it can be provided in pflash images).

Signed-off-by: Dmitry Eremin-Solenikov dbarysh...@gmail.com
---
 Makefile.target |1 +
 hw/collie.c |   70 +++
 2 files changed, 71 insertions(+), 0 deletions(-)
 create mode 100644 hw/collie.c

diff --git a/Makefile.target b/Makefile.target
index d071a4d..abc2978 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -329,6 +329,7 @@ obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o 
syborg_keyboard.o
 obj-arm-y += syborg_serial.o syborg_timer.o syborg_pointer.o syborg_rtc.o
 obj-arm-y += syborg_virtio.o
 obj-arm-y += strongarm.o
+obj-arm-y += collie.o
 
 obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
 obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o
diff --git a/hw/collie.c b/hw/collie.c
new file mode 100644
index 000..965fd13
--- /dev/null
+++ b/hw/collie.c
@@ -0,0 +1,70 @@
+/*
+ * SA-1110-based Sharp Zaurus SL-5500 platform.
+ *
+ * Copyright (C) 2011 Dmitry Eremin-Solenikov
+ *
+ * This code is licensed under GNU GPL v2.
+ */
+#include hw.h
+#include sysbus.h
+#include boards.h
+#include devices.h
+#include strongarm.h
+#include arm-misc.h
+#include flash.h
+#include blockdev.h
+
+static struct arm_boot_info collie_binfo = {
+.loader_start = SA_SDCS0,
+.ram_size = 0x2000,
+};
+
+static void collie_init(ram_addr_t ram_size,
+const char *boot_device,
+const char *kernel_filename, const char *kernel_cmdline,
+const char *initrd_filename, const char *cpu_model)
+{
+StrongARMState *s;
+DriveInfo *dinfo;
+ram_addr_t phys_flash;
+
+if (!cpu_model) {
+cpu_model = sa1110;
+}
+
+s = sa1110_init(collie_binfo.ram_size, cpu_model);
+(void) s;
+
+phys_flash = qemu_ram_alloc(NULL, collie.fl1, 0x0200);
+dinfo = drive_get(IF_PFLASH, 0, 0);
+pflash_cfi01_register(SA_CS0, phys_flash,
+dinfo ? dinfo-bdrv : NULL, (64 * 1024),
+512, 4, 0x00, 0x00, 0x00, 0x00, 0);
+
+phys_flash = qemu_ram_alloc(NULL, collie.fl2, 0x0200);
+dinfo = drive_get(IF_PFLASH, 0, 1);
+pflash_cfi01_register(SA_CS1, phys_flash,
+dinfo ? dinfo-bdrv : NULL, (64 * 1024),
+512, 4, 0x00, 0x00, 0x00, 0x00, 0);
+
+sysbus_create_simple(scoop, 0x4080, NULL);
+
+collie_binfo.kernel_filename = kernel_filename;
+collie_binfo.kernel_cmdline = kernel_cmdline;
+collie_binfo.initrd_filename = initrd_filename;
+collie_binfo.board_id = 0x208;
+arm_load_kernel(s-env, collie_binfo);
+}
+
+static QEMUMachine collie_machine = {
+.name = collie,
+.desc = Collie PDA (SA-1110),
+.init = collie_init,
+};
+
+static void collie_machine_init(void)
+{
+qemu_register_machine(collie_machine);
+}
+
+machine_init(collie_machine_init)
-- 
1.7.4.1




[Qemu-devel] [PATCH 1/3] arm: basic support for ARMv4/ARMv4T emulation

2011-03-29 Thread Dmitry Eremin-Solenikov
Currently target-arm/ assumes at least ARMv5 core. Add support for
handling also ARMv4/ARMv4T. This changes the following instructions:

BX(v4T and later)

BKPT, BLX, CDP2, CLZ, LDC2, LDRD, MCRR, MCRR2, MRRC, MCRR, MRC2, MRRC,
MRRC2, PLD QADD, QDADD, QDSUB, QSUB, STRD, SMLAxy, SMLALxy, SMLAWxy,
SMULxy, SMULWxy, STC2 (v5 and later)

All instructions that are v5TE and later are also bound to just v5, as
that's how it was before.

This patch doesn _not_ include disabling of cp15 access and base-updated
data abort model (that will be required to emulate chips based on a
ARM7TDMI), because:
* no ARM7TDMI chips are currently emulated (or planned)
* those features aren't strictly necessary for my purposes (SA-1 core
  emulation).

All v5 models are handled as they are v5T. Internally we still have a
check if the model is a v5(T) or v5TE, but as all emulated cores are
v5TE, those two cases are simply aliased (for now).

Patch is heavily based on patch by Filip Navara filip.nav...@gmail.com
which in turn is based on work by Ulrich Hecht u...@suse.de and Vincent
Sanders vi...@kyllikki.org.

Signed-off-by: Dmitry Eremin-Solenikov dbarysh...@gmail.com
---
 target-arm/cpu.h   |4 +++-
 target-arm/helper.c|   23 +++
 target-arm/translate.c |   42 +-
 3 files changed, 63 insertions(+), 6 deletions(-)

diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 1ae7982..e247a7a 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -360,7 +360,9 @@ enum arm_features {
 ARM_FEATURE_M, /* Microcontroller profile.  */
 ARM_FEATURE_OMAPCP, /* OMAP specific CP15 ops handling.  */
 ARM_FEATURE_THUMB2EE,
-ARM_FEATURE_V7MP/* v7 Multiprocessing Extensions */
+ARM_FEATURE_V7MP,/* v7 Multiprocessing Extensions */
+ARM_FEATURE_V4T,
+ARM_FEATURE_V5,
 };
 
 static inline int arm_feature(CPUARMState *env, int feature)
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 78f3d39..261e148 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -48,17 +48,23 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t 
id)
 env-cp15.c0_cpuid = id;
 switch (id) {
 case ARM_CPUID_ARM926:
+set_feature(env, ARM_FEATURE_V4T);
+set_feature(env, ARM_FEATURE_V5);
 set_feature(env, ARM_FEATURE_VFP);
 env-vfp.xregs[ARM_VFP_FPSID] = 0x41011090;
 env-cp15.c0_cachetype = 0x1dd20d2;
 env-cp15.c1_sys = 0x00090078;
 break;
 case ARM_CPUID_ARM946:
+set_feature(env, ARM_FEATURE_V4T);
+set_feature(env, ARM_FEATURE_V5);
 set_feature(env, ARM_FEATURE_MPU);
 env-cp15.c0_cachetype = 0x0f004006;
 env-cp15.c1_sys = 0x0078;
 break;
 case ARM_CPUID_ARM1026:
+set_feature(env, ARM_FEATURE_V4T);
+set_feature(env, ARM_FEATURE_V5);
 set_feature(env, ARM_FEATURE_VFP);
 set_feature(env, ARM_FEATURE_AUXCR);
 env-vfp.xregs[ARM_VFP_FPSID] = 0x410110a0;
@@ -67,6 +73,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
 break;
 case ARM_CPUID_ARM1136_R2:
 case ARM_CPUID_ARM1136:
+set_feature(env, ARM_FEATURE_V4T);
+set_feature(env, ARM_FEATURE_V5);
 set_feature(env, ARM_FEATURE_V6);
 set_feature(env, ARM_FEATURE_VFP);
 set_feature(env, ARM_FEATURE_AUXCR);
@@ -79,6 +87,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
 env-cp15.c1_sys = 0x00050078;
 break;
 case ARM_CPUID_ARM11MPCORE:
+set_feature(env, ARM_FEATURE_V4T);
+set_feature(env, ARM_FEATURE_V5);
 set_feature(env, ARM_FEATURE_V6);
 set_feature(env, ARM_FEATURE_V6K);
 set_feature(env, ARM_FEATURE_VFP);
@@ -91,6 +101,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
 env-cp15.c0_cachetype = 0x1dd20d2;
 break;
 case ARM_CPUID_CORTEXA8:
+set_feature(env, ARM_FEATURE_V4T);
+set_feature(env, ARM_FEATURE_V5);
 set_feature(env, ARM_FEATURE_V6);
 set_feature(env, ARM_FEATURE_V6K);
 set_feature(env, ARM_FEATURE_V7);
@@ -113,6 +125,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t 
id)
 env-cp15.c1_sys = 0x00c50078;
 break;
 case ARM_CPUID_CORTEXA9:
+set_feature(env, ARM_FEATURE_V4T);
+set_feature(env, ARM_FEATURE_V5);
 set_feature(env, ARM_FEATURE_V6);
 set_feature(env, ARM_FEATURE_V6K);
 set_feature(env, ARM_FEATURE_V7);
@@ -140,6 +154,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t 
id)
 env-cp15.c1_sys = 0x00c50078;
 break;
 case ARM_CPUID_CORTEXM3:
+set_feature(env, ARM_FEATURE_V4T);
+set_feature(env, ARM_FEATURE_V5);
 set_feature(env, ARM_FEATURE_V6);
 set_feature(env, ARM_FEATURE_THUMB2);
 set_feature(env, ARM_FEATURE_V7);
@@ -147,6 +163,8 @@ static void 

[Qemu-devel] Re: [PATCH 3/4] Introduce machine state

2011-03-29 Thread Blue Swirl
On Tue, Mar 29, 2011 at 11:14 AM, Paolo Bonzini pbonz...@redhat.com wrote:
 On 03/28/2011 07:21 PM, Blue Swirl wrote:

 
   What's the distinction between vm state and machine state?

 VM state should be invisible (except for PV devices).

 Got it.  That's why I called it emulator state (a bit generic, but more
 precise than vm state: vm_clock for example is guest-visible).

 About 'machine', I was thinking about -M switch to specify
 the emulated machine type.

 Yes, makes sense.  I actually like the name machine state, as long as you
 rename what you called virtual machine state.

OK, I'll change 'vm' to 'emulator'. Thanks for the review.



Re: [Qemu-devel] [PATCH 1/3] arm: basic support for ARMv4/ARMv4T emulation

2011-03-29 Thread Peter Maydell
On 29 March 2011 17:58, Dmitry Eremin-Solenikov dbarysh...@gmail.com wrote:

Looks good, nearly there I think.

 @@ -7172,10 +7191,11 @@ static void disas_arm_insn(CPUState * env, 
 DisasContext *s)
             }
             if (insn  (1  20)) {
                 /* Complete the load.  */
 -                if (rd == 15)
 +                if (rd == 15  ENABLE_ARCH_4T) {
                     gen_bx(s, tmp);
 -                else
 +                } else {
                     store_reg(s, rd, tmp);
 +                }
             }
             break;
         case 0x08:

Shouldn't this be ENABLE_ARCH_5T ? Loads to PC are only interworking
in v5T and above.
(But see below...)

 @@ -7229,7 +7249,11 @@ static void disas_arm_insn(CPUState * env, 
 DisasContext *s)
                             /* load */
                             tmp = gen_ld32(addr, IS_USER(s));
                             if (i == 15) {
 -                                gen_bx(s, tmp);
 +                                if (ENABLE_ARCH_5) {
 +                                    gen_bx(s, tmp);
 +                                } else {
 +                                    store_reg(s, i, tmp);
 +                                }
                             } else if (user) {
                                 tmp2 = tcg_const_i32(i);
                                 gen_helper_set_user_reg(tmp2, tmp);


 @@ -8980,8 +9006,13 @@ static void disas_thumb_insn(CPUState *env, 
 DisasContext *s)
             /* write back the new stack pointer */
             store_reg(s, 13, addr);
             /* set the new PC value */
 -            if ((insn  0x0900) == 0x0900)
 -                gen_bx(s, tmp);
 +            if ((insn  0x0900) == 0x0900) {
 +                if (ENABLE_ARCH_5) {
 +                    gen_bx(s, tmp);
 +                } else {
 +                    store_reg(s, 15, tmp);
 +                }
 +            }
             break;

         case 1: case 3: case 9: case 11: /* czb */

These two are right, but I think we should have a utility function
(put it next to store_reg_bx()):

/* Variant of store_reg which uses branchexchange logic when storing
 * to r15 in ARM architecture v5T and above. This is used for storing
 * the results of a LDR/LDM/POP into r15, and corresponds to the cases
 * in the ARM ARM which use the LoadWritePC() pseudocode function.
 */
static inline void store_reg_from_load(CPUState *env, DisasContext *s,
   int reg, TCGv var)
{
if (reg == 15  ENABLE_ARCH_5TE) {
gen_bx(s, var);
} else {
store_reg(s, reg, var);
}
}

Then you can use this in the three code hunks above. (You'll want
to tweak the middle one, you can move it to
  if (user) {
...
  } else if (i == rn) {
...
  } else {
store_reg_from_load(env, s, i, tmp);
  }

because if i==15 then user must be false, and if rn == 15 this
is UNPREDICTABLE anyway.)

These comments from last round still hold for this patch:

The CPSR Q bit needs to RAZ/WI on v4 and v4T.

For v4 you need to make sure that the core can't get into
thumb mode at all. So feature guards in gen_bx_imm() and
gen_bx(), make sure PSR masks prevent the T bit getting set,
and check helper.c for anything that sets env-thumb from
somewhere else...

-- PMM


[Qemu-devel] [PATCH V12 00/17] Xen device model support

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

Hi all,

Here is the few change made since the v11:
  - All objects built for each target are now build only for i386 targets.
  - The compatibility macros have been replaced by static inline functions.
  - xen_platform_init replaced by a call to pci_create_simple.
  - Use of bitmap.h in xen mapcache
  - Xen Mapcache have a max cache limit now.
  - Compilation of x86_64 target fixed.
  - A ram_ptr leak is fixed in pci_add_option_rom.

This series depends on the series Introduce machine QemuOpts.

You can find a git tree here:

git://xenbits.xen.org/people/aperard/qemu-dm.git qemu-dm-v12


Anthony PERARD (12):
  xen: Replace some tab-indents with spaces (clean-up).
  xen: Make Xen build once.
  xen: Support new libxc calls from xen unstable.
  xen: Add initialisation of Xen
  xen: Add xenfv machine
  piix_pci: Introduces Xen specific call for irq.
  xen: Introduce Xen Interrupt Controller
  configure: Always use 64bits target physical addresses with xen
enabled.
  Introduce qemu_put_ram_ptr
  vl.c: Introduce getter for shutdown_requested and reset_requested.
  xen: Set running state in xenstore.
  xen: Add Xen hypercall for sleep state in the cmos_s3 callback.

Arun Sharma (1):
  xen: Initialize event channels and io rings

John Baboval (2):
  xen: Adds a cap to the number of map cache entries.
  pci: Use of qemu_put_ram_ptr in pci_add_option_rom.

Jun Nakajima (1):
  xen: Introduce the Xen mapcache

Steven Smith (1):
  xen: Add the Xen platform pci device

 Makefile.target  |   16 ++-
 configure|   71 ++-
 cpu-common.h |1 +
 exec.c   |   50 -
 hw/hw.h  |3 +
 hw/pc.c  |   19 ++-
 hw/pc.h  |1 +
 hw/pc_piix.c |   41 -
 hw/pci.c |2 +
 hw/pci_ids.h |2 +
 hw/piix_pci.c|   47 -
 hw/xen.h |   39 
 hw/xen_backend.c |  422 
 hw/xen_backend.h |6 +-
 hw/xen_common.h  |  106 --
 hw/xen_disk.c|  496 +++
 hw/xen_domainbuild.c |3 +-
 hw/xen_nic.c |  265 ---
 hw/xen_platform.c|  340 +
 roms/seabios |2 +-
 sysemu.h |2 +
 trace-events |3 +
 vl.c |   12 +
 xen-all.c|  581 ++
 xen-mapcache-stub.c  |   40 
 xen-mapcache.c   |  343 +
 xen-mapcache.h   |   22 ++
 xen-stub.c   |   41 
 28 files changed, 2400 insertions(+), 576 deletions(-)
 create mode 100644 hw/xen_platform.c
 create mode 100644 xen-all.c
 create mode 100644 xen-mapcache-stub.c
 create mode 100644 xen-mapcache.c
 create mode 100644 xen-mapcache.h
 create mode 100644 xen-stub.c

-- 
1.7.2.3




[Qemu-devel] [PATCH V12 04/17] xen: Add initialisation of Xen

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

Signed-off-by: Anthony PERARD anthony.per...@citrix.com
Acked-by: Alexander Graf ag...@suse.de
---
 Makefile.target |9 +
 hw/xen.h|   13 +
 vl.c|2 ++
 xen-all.c   |   23 +++
 xen-stub.c  |   15 +++
 5 files changed, 62 insertions(+), 0 deletions(-)
 create mode 100644 xen-all.c
 create mode 100644 xen-stub.c

diff --git a/Makefile.target b/Makefile.target
index e8ffc7c..b235774 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -208,6 +208,15 @@ QEMU_CFLAGS += $(VNC_PNG_CFLAGS)
 # xen backend driver support
 obj-i386-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o
 
+ifeq ($(TARGET_BASE_ARCH), i386)
+  CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y)
+else
+  CONFIG_NO_XEN = y
+endif
+# xen support
+obj-i386-$(CONFIG_XEN) += xen-all.o
+obj-$(CONFIG_NO_XEN) += xen-stub.o
+
 # Inter-VM PCI shared memory
 obj-$(CONFIG_KVM) += ivshmem.o
 
diff --git a/hw/xen.h b/hw/xen.h
index 780dcf7..1fefe3a 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -18,4 +18,17 @@ enum xen_mode {
 extern uint32_t xen_domid;
 extern enum xen_mode xen_mode;
 
+extern int xen_allowed;
+
+static inline int xen_enabled(void)
+{
+#ifdef CONFIG_XEN
+return xen_allowed;
+#else
+return 0;
+#endif
+}
+
+int xen_init(void);
+
 #endif /* QEMU_HW_XEN_H */
diff --git a/vl.c b/vl.c
index 2209a4d..5ba1eb9 100644
--- a/vl.c
+++ b/vl.c
@@ -259,6 +259,7 @@ static NotifierList machine_init_done_notifiers =
 
 static int tcg_allowed = 1;
 int kvm_allowed = 0;
+int xen_allowed = 0;
 uint32_t xen_domid;
 enum xen_mode xen_mode = XEN_EMULATE;
 
@@ -1979,6 +1980,7 @@ static struct {
 int *allowed;
 } accel_list[] = {
 { tcg, tcg, tcg_available, tcg_init, tcg_allowed },
+{ xen, Xen, xen_available, xen_init, xen_allowed },
 { kvm, KVM, kvm_available, kvm_init, kvm_allowed },
 };
 
diff --git a/xen-all.c b/xen-all.c
new file mode 100644
index 000..e2872f9
--- /dev/null
+++ b/xen-all.c
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010   Citrix Ltd.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#include hw/xen_common.h
+#include hw/xen_backend.h
+
+/* Initialise Xen */
+
+int xen_init(void)
+{
+xen_xc = xen_xc_interface_open(0, 0, 0);
+if (xen_xc == XC_HANDLER_INITIAL_VALUE) {
+xen_be_printf(NULL, 0, can't open xen interface\n);
+return -1;
+}
+
+return 0;
+}
diff --git a/xen-stub.c b/xen-stub.c
new file mode 100644
index 000..beb982f
--- /dev/null
+++ b/xen-stub.c
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2010   Citrix Ltd.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#include qemu-common.h
+#include hw/xen.h
+
+int xen_init(void)
+{
+return -ENOSYS;
+}
-- 
1.7.2.3




[Qemu-devel] [PATCH V12 06/17] xen: Add the Xen platform pci device

2011-03-29 Thread anthony . perard
From: Steven Smith ssm...@xensource.com

Introduce a new emulated PCI device, specific to fully virtualized Xen
guests.  The device is necessary for PV on HVM drivers to work.

Signed-off-by: Steven Smith ssm...@xensource.com
Signed-off-by: Anthony PERARD anthony.per...@citrix.com
Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com
---
 Makefile.target   |2 +
 hw/hw.h   |3 +
 hw/pc_piix.c  |4 +
 hw/pci_ids.h  |2 +
 hw/xen_platform.c |  340 +
 trace-events  |3 +
 6 files changed, 354 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen_platform.c

diff --git a/Makefile.target b/Makefile.target
index b235774..8d5c75b 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -217,6 +217,8 @@ endif
 obj-i386-$(CONFIG_XEN) += xen-all.o
 obj-$(CONFIG_NO_XEN) += xen-stub.o
 
+obj-i386-$(CONFIG_XEN) += xen_platform.o
+
 # Inter-VM PCI shared memory
 obj-$(CONFIG_KVM) += ivshmem.o
 
diff --git a/hw/hw.h b/hw/hw.h
index 1b09039..a22c92d 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -769,6 +769,9 @@ extern const VMStateDescription vmstate_usb_device;
 #define VMSTATE_INT32_LE(_f, _s)   \
 VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
 
+#define VMSTATE_UINT8_TEST(_f, _s, _t)   \
+VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
+
 #define VMSTATE_UINT16_TEST(_f, _s, _t)   \
 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
 
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 6eff06e..8e5023e 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -121,6 +121,10 @@ static void pc_init1(ram_addr_t ram_size,
 
 pc_vga_init(pci_enabled? pci_bus: NULL);
 
+if (xen_enabled()) {
+pci_create_simple(pci_bus, -1, xen-platform);
+}
+
 /* init basic PC hardware */
 pc_basic_device_init(isa_irq, rtc_state);
 
diff --git a/hw/pci_ids.h b/hw/pci_ids.h
index ea3418c..6e9eabc 100644
--- a/hw/pci_ids.h
+++ b/hw/pci_ids.h
@@ -108,3 +108,5 @@
 #define PCI_DEVICE_ID_INTEL_82371AB  0x7111
 #define PCI_DEVICE_ID_INTEL_82371AB_20x7112
 #define PCI_DEVICE_ID_INTEL_82371AB_30x7113
+
+#define PCI_VENDOR_ID_XENSOURCE  0x5853
diff --git a/hw/xen_platform.c b/hw/xen_platform.c
new file mode 100644
index 000..b167eee
--- /dev/null
+++ b/hw/xen_platform.c
@@ -0,0 +1,340 @@
+/*
+ * XEN platform pci device, formerly known as the event channel device
+ *
+ * Copyright (c) 2003-2004 Intel Corp.
+ * Copyright (c) 2006 XenSource
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include assert.h
+
+#include hw.h
+#include pc.h
+#include pci.h
+#include irq.h
+#include xen_common.h
+#include net.h
+#include xen_backend.h
+#include rwhandler.h
+#include trace.h
+
+#include xenguest.h
+
+//#define DEBUG_PLATFORM
+
+#ifdef DEBUG_PLATFORM
+#define DPRINTF(fmt, ...) do { \
+fprintf(stderr, xen_platform:  fmt, ## __VA_ARGS__); \
+} while (0)
+#else
+#define DPRINTF(fmt, ...) do { } while (0)
+#endif
+
+#define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */
+
+typedef struct PCIXenPlatformState {
+PCIDevice  pci_dev;
+uint8_t flags; /* used only for version_id == 2 */
+int drivers_blacklisted;
+uint16_t driver_product_version;
+
+/* Log from guest drivers */
+char log_buffer[4096];
+int log_buffer_off;
+} PCIXenPlatformState;
+
+#define XEN_PLATFORM_IOPORT 0x10
+
+/* Send bytes to syslog */
+static void log_writeb(PCIXenPlatformState *s, char val)
+{
+if (val == '\n' || s-log_buffer_off == sizeof(s-log_buffer) - 1) {
+/* Flush buffer */
+s-log_buffer[s-log_buffer_off] = 0;
+trace_xen_platform_log(s-log_buffer);
+s-log_buffer_off = 0;
+} else {
+s-log_buffer[s-log_buffer_off++] = val;
+}
+}
+
+/* Xen Platform, Fixed IOPort */
+
+static void 

[Qemu-devel] [PATCH V12 02/17] xen: Make Xen build once.

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

xen_domainbuild and xen_machine_pv are built only for i386 targets.

Signed-off-by: Anthony PERARD anthony.per...@citrix.com
---
 Makefile.target |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 62b102a..e8ffc7c 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -206,7 +206,7 @@ QEMU_CFLAGS += $(VNC_JPEG_CFLAGS)
 QEMU_CFLAGS += $(VNC_PNG_CFLAGS)
 
 # xen backend driver support
-obj-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o
+obj-i386-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o
 
 # Inter-VM PCI shared memory
 obj-$(CONFIG_KVM) += ivshmem.o
-- 
1.7.2.3




[Qemu-devel] [PATCH V12 03/17] xen: Support new libxc calls from xen unstable.

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

This patch updates the libxenctrl calls in Qemu to use the new interface,
otherwise Qemu wouldn't be able to build against new versions of the
library.

We check libxenctrl version in configure, from Xen 3.3.0 to Xen
unstable.

Signed-off-by: Anthony PERARD anthony.per...@citrix.com
Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com
Acked-by: Alexander Graf ag...@suse.de
---
 configure|   67 ++-
 hw/xen_backend.c |   21 ++-
 hw/xen_backend.h |6 ++--
 hw/xen_common.h  |   95 ++---
 hw/xen_disk.c|4 +-
 hw/xen_domainbuild.c |3 +-
 6 files changed, 164 insertions(+), 32 deletions(-)

diff --git a/configure b/configure
index 5a5827f..bc6552e 100755
--- a/configure
+++ b/configure
@@ -127,6 +127,7 @@ vnc_jpeg=
 vnc_png=
 vnc_thread=no
 xen=
+xen_ctrl_version=
 linux_aio=
 attr=
 vhost_net=
@@ -1155,20 +1156,81 @@ fi
 
 if test $xen != no ; then
   xen_libs=-lxenstore -lxenctrl -lxenguest
+
+  # Xen unstable
   cat  $TMPC EOF
 #include xenctrl.h
 #include xs.h
-int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
+#include stdint.h
+#include xen/hvm/hvm_info_table.h
+#if !defined(HVM_MAX_VCPUS)
+# error HVM_MAX_VCPUS not defined
+#endif
+int main(void) {
+  xc_interface *xc;
+  xs_daemon_open();
+  xc = xc_interface_open(0, 0, 0);
+  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
+  xc_gnttab_open(NULL, 0);
+  return 0;
+}
 EOF
   if compile_prog  $xen_libs ; then
+xen_ctrl_version=410
 xen=yes
-libs_softmmu=$xen_libs $libs_softmmu
+
+  # Xen 4.0.0
+  elif (
+  cat  $TMPC EOF
+#include xenctrl.h
+#include xs.h
+#include stdint.h
+#include xen/hvm/hvm_info_table.h
+#if !defined(HVM_MAX_VCPUS)
+# error HVM_MAX_VCPUS not defined
+#endif
+int main(void) {
+  xs_daemon_open();
+  xc_interface_open();
+  xc_gnttab_open();
+  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
+  return 0;
+}
+EOF
+  compile_prog  $xen_libs
+) ; then
+xen_ctrl_version=400
+xen=yes
+
+  # Xen 3.3.0, 3.4.0
+  elif (
+  cat  $TMPC EOF
+#include xenctrl.h
+#include xs.h
+int main(void) {
+  xs_daemon_open();
+  xc_interface_open();
+  xc_gnttab_open();
+  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
+  return 0;
+}
+EOF
+  compile_prog  $xen_libs
+) ; then
+xen_ctrl_version=330
+xen=yes
+
+  # Xen not found or unsupported
   else
 if test $xen = yes ; then
   feature_not_found xen
 fi
 xen=no
   fi
+
+  if test $xen = yes; then
+libs_softmmu=$xen_libs $libs_softmmu
+  fi
 fi
 
 ##
@@ -2772,6 +2834,7 @@ if test $bluez = yes ; then
 fi
 if test $xen = yes ; then
   echo CONFIG_XEN=y  $config_host_mak
+  echo CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version  
$config_host_mak
 fi
 if test $io_thread = yes ; then
   echo CONFIG_IOTHREAD=y  $config_host_mak
diff --git a/hw/xen_backend.c b/hw/xen_backend.c
index 9f4ec4b..5f58a3f 100644
--- a/hw/xen_backend.c
+++ b/hw/xen_backend.c
@@ -43,7 +43,8 @@
 /* - */
 
 /* public */
-int xen_xc;
+XenXC xen_xc = XC_HANDLER_INITIAL_VALUE;
+XenGnttab xen_xcg = XC_HANDLER_INITIAL_VALUE;
 struct xs_handle *xenstore = NULL;
 const char *xen_protocol;
 
@@ -214,8 +215,8 @@ static struct XenDevice *xen_be_get_xendev(const char 
*type, int dom, int dev,
 xendev-debug  = debug;
 xendev-local_port = -1;
 
-xendev-evtchndev = xc_evtchn_open();
-if (xendev-evtchndev  0) {
+xendev-evtchndev = xen_xc_evtchn_open(NULL, 0);
+if (xendev-evtchndev == XC_HANDLER_INITIAL_VALUE) {
 xen_be_printf(NULL, 0, can't open evtchn device\n);
 qemu_free(xendev);
 return NULL;
@@ -223,15 +224,15 @@ static struct XenDevice *xen_be_get_xendev(const char 
*type, int dom, int dev,
 fcntl(xc_evtchn_fd(xendev-evtchndev), F_SETFD, FD_CLOEXEC);
 
 if (ops-flags  DEVOPS_FLAG_NEED_GNTDEV) {
-xendev-gnttabdev = xc_gnttab_open();
-if (xendev-gnttabdev  0) {
+xendev-gnttabdev = xen_xc_gnttab_open(NULL, 0);
+if (xendev-gnttabdev == XC_HANDLER_INITIAL_VALUE) {
 xen_be_printf(NULL, 0, can't open gnttab device\n);
 xc_evtchn_close(xendev-evtchndev);
 qemu_free(xendev);
 return NULL;
 }
 } else {
-xendev-gnttabdev = -1;
+xendev-gnttabdev = XC_HANDLER_INITIAL_VALUE;
 }
 
 QTAILQ_INSERT_TAIL(xendevs, xendev, next);
@@ -277,10 +278,10 @@ static struct XenDevice *xen_be_del_xendev(int dom, int 
dev)
 qemu_free(xendev-fe);
 }
 
-if (xendev-evtchndev = 0) {
+if (xendev-evtchndev != XC_HANDLER_INITIAL_VALUE) {
 xc_evtchn_close(xendev-evtchndev);
 }
-if (xendev-gnttabdev = 0) {
+if (xendev-gnttabdev != XC_HANDLER_INITIAL_VALUE) {
 

[Qemu-devel] [PATCH V12 07/17] piix_pci: Introduces Xen specific call for irq.

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

This patch introduces Xen specific call in piix_pci.

The specific part for Xen is in write_config, set_irq and get_pirq.

Signed-off-by: Anthony PERARD anthony.per...@citrix.com
Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com
Acked-by: Alexander Graf ag...@suse.de
---
 hw/pc.h   |1 +
 hw/pc_piix.c  |6 +-
 hw/piix_pci.c |   47 ---
 hw/xen.h  |6 ++
 xen-all.c |   31 +++
 xen-stub.c|   13 +
 6 files changed, 100 insertions(+), 4 deletions(-)

diff --git a/hw/pc.h b/hw/pc.h
index feb8a7a..85662c3 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -176,6 +176,7 @@ struct PCII440FXState;
 typedef struct PCII440FXState PCII440FXState;
 
 PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, qemu_irq 
*pic, ram_addr_t ram_size);
+PCIBus *i440fx_xen_init(PCII440FXState **pi440fx_state, int *piix3_devfn, 
qemu_irq *pic, ram_addr_t ram_size);
 void i440fx_init_memory_mappings(PCII440FXState *d);
 
 /* piix4.c */
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 8e5023e..b9b99d2 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -109,7 +109,11 @@ static void pc_init1(ram_addr_t ram_size,
 isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
 
 if (pci_enabled) {
-pci_bus = i440fx_init(i440fx_state, piix3_devfn, isa_irq, ram_size);
+if (!xen_enabled()) {
+pci_bus = i440fx_init(i440fx_state, piix3_devfn, isa_irq, 
ram_size);
+} else {
+pci_bus = i440fx_xen_init(i440fx_state, piix3_devfn, isa_irq, 
ram_size);
+}
 } else {
 pci_bus = NULL;
 i440fx_state = NULL;
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 358da58..c11a7f6 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -29,6 +29,7 @@
 #include isa.h
 #include sysbus.h
 #include range.h
+#include xen.h
 
 /*
  * I440FX chipset data sheet.
@@ -151,6 +152,13 @@ static void i440fx_write_config(PCIDevice *dev,
 }
 }
 
+static void i440fx_write_config_xen(PCIDevice *dev,
+uint32_t address, uint32_t val, int len)
+{
+xen_piix_pci_write_config_client(address, val, len);
+i440fx_write_config(dev, address, val, len);
+}
+
 static int i440fx_load_old(QEMUFile* f, void *opaque, int version_id)
 {
 PCII440FXState *d = opaque;
@@ -216,7 +224,10 @@ static int i440fx_initfn(PCIDevice *dev)
 return 0;
 }
 
-PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq 
*pic, ram_addr_t ram_size)
+static PCIBus *i440fx_common_init(const char *device_name,
+  PCII440FXState **pi440fx_state,
+  int *piix3_devfn,
+  qemu_irq *pic, ram_addr_t ram_size)
 {
 DeviceState *dev;
 PCIBus *b;
@@ -230,13 +241,13 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int 
*piix3_devfn, qemu_irq *
 s-bus = b;
 qdev_init_nofail(dev);
 
-d = pci_create_simple(b, 0, i440FX);
+d = pci_create_simple(b, 0, device_name);
 *pi440fx_state = DO_UPCAST(PCII440FXState, dev, d);
 
 piix3 = DO_UPCAST(PIIX3State, dev,
   pci_create_simple_multifunction(b, -1, true, PIIX3));
 piix3-pic = pic;
-pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3, 4);
+
 (*pi440fx_state)-piix3 = piix3;
 
 *piix3_devfn = piix3-dev.devfn;
@@ -249,6 +260,28 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int 
*piix3_devfn, qemu_irq *
 return b;
 }
 
+PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
+qemu_irq *pic, ram_addr_t ram_size)
+{
+PCIBus *b;
+
+b = i440fx_common_init(i440FX, pi440fx_state, piix3_devfn, pic, 
ram_size);
+pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, (*pi440fx_state)-piix3, 
4);
+
+return b;
+}
+
+PCIBus *i440fx_xen_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
+qemu_irq *pic, ram_addr_t ram_size)
+{
+PCIBus *b;
+
+b = i440fx_common_init(i440FX-xen, pi440fx_state, piix3_devfn, pic, 
ram_size);
+pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq, 
(*pi440fx_state)-piix3, 4);
+
+return b;
+}
+
 /* PIIX3 PCI to ISA bridge */
 
 static void piix3_set_irq(void *opaque, int irq_num, int level)
@@ -352,6 +385,14 @@ static PCIDeviceInfo i440fx_info[] = {
 .init = i440fx_initfn,
 .config_write = i440fx_write_config,
 },{
+.qdev.name= i440FX-xen,
+.qdev.desc= Host bridge,
+.qdev.size= sizeof(PCII440FXState),
+.qdev.vmsd= vmstate_i440fx,
+.qdev.no_user = 1,
+.init = i440fx_initfn,
+.config_write = i440fx_write_config_xen,
+},{
 .qdev.name= PIIX3,
 .qdev.desc= ISA bridge,
 .qdev.size= sizeof(PIIX3State),
diff --git a/hw/xen.h b/hw/xen.h

[Qemu-devel] [PATCH V12 09/17] xen: Introduce the Xen mapcache

2011-03-29 Thread anthony . perard
From: Jun Nakajima jun.nakaj...@intel.com

On IA32 host or IA32 PAE host, at present, generally, we can't create
an HVM guest with more than 2G memory, because generally it's almost
impossible for Qemu to find a large enough and consecutive virtual
address space to map an HVM guest's whole physical address space.
The attached patch fixes this issue using dynamic mapping based on
little blocks of memory.

Each call to qemu_get_ram_ptr makes a call to qemu_map_cache with the
lock option, so mapcache will not unmap these ram_ptr.

Signed-off-by: Jun Nakajima jun.nakaj...@intel.com
Signed-off-by: Anthony PERARD anthony.per...@citrix.com
Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com
---
 Makefile.target |3 +
 configure   |3 +
 exec.c  |   40 ++-
 hw/xen.h|   13 ++
 hw/xen_common.h |9 ++
 xen-all.c   |   64 +++
 xen-mapcache-stub.c |   40 +++
 xen-mapcache.c  |  310 +++
 xen-mapcache.h  |   22 
 xen-stub.c  |4 +
 10 files changed, 504 insertions(+), 4 deletions(-)
 create mode 100644 xen-mapcache-stub.c
 create mode 100644 xen-mapcache.c
 create mode 100644 xen-mapcache.h

diff --git a/Makefile.target b/Makefile.target
index 8d5c75b..245d2a2 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -214,8 +214,11 @@ else
   CONFIG_NO_XEN = y
 endif
 # xen support
+CONFIG_NO_XEN_MAPCACHE = $(if $(subst n,,$(CONFIG_XEN_MAPCACHE)),n,y)
 obj-i386-$(CONFIG_XEN) += xen-all.o
 obj-$(CONFIG_NO_XEN) += xen-stub.o
+obj-i386-$(CONFIG_XEN_MAPCACHE) += xen-mapcache.o
+obj-$(CONFIG_NO_XEN_MAPCACHE) += xen-mapcache-stub.o
 
 obj-i386-$(CONFIG_XEN) += xen_platform.o
 
diff --git a/configure b/configure
index bc6552e..309b210 100755
--- a/configure
+++ b/configure
@@ -3191,6 +3191,9 @@ case $target_arch2 in
   i386|x86_64)
 if test $xen = yes -a $target_softmmu = yes ; then
   echo CONFIG_XEN=y  $config_target_mak
+  if test $cpu = i386 -o $cpu = x86_64; then
+  echo CONFIG_XEN_MAPCACHE=y  $config_target_mak
+  fi
 fi
 esac
 case $target_arch2 in
diff --git a/exec.c b/exec.c
index 964ce31..941abce 100644
--- a/exec.c
+++ b/exec.c
@@ -32,6 +32,7 @@
 #include hw/qdev.h
 #include osdep.h
 #include kvm.h
+#include hw/xen.h
 #include qemu-timer.h
 #if defined(CONFIG_USER_ONLY)
 #include qemu.h
@@ -51,6 +52,8 @@
 #include libutil.h
 #endif
 #endif
+#else /* !CONFIG_USER_ONLY */
+#include xen-mapcache.h
 #endif
 
 //#define DEBUG_TB_INVALIDATE
@@ -2868,6 +2871,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, 
const char *name,
 }
 }
 
+new_block-offset = find_ram_offset(size);
 if (host) {
 new_block-host = host;
 new_block-flags |= RAM_PREALLOC_MASK;
@@ -2890,13 +2894,15 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, 
const char *name,
PROT_EXEC|PROT_READ|PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
 #else
-new_block-host = qemu_vmalloc(size);
+if (xen_mapcache_enabled()) {
+xen_ram_alloc(new_block-offset, size);
+} else {
+new_block-host = qemu_vmalloc(size);
+}
 #endif
 qemu_madvise(new_block-host, size, QEMU_MADV_MERGEABLE);
 }
 }
-
-new_block-offset = find_ram_offset(size);
 new_block-length = size;
 
 QLIST_INSERT_HEAD(ram_list.blocks, new_block, next);
@@ -2941,7 +2947,11 @@ void qemu_ram_free(ram_addr_t addr)
 #if defined(TARGET_S390X)  defined(CONFIG_KVM)
 munmap(block-host, block-length);
 #else
-qemu_vfree(block-host);
+if (xen_mapcache_enabled()) {
+qemu_invalidate_entry(block-host);
+} else {
+qemu_vfree(block-host);
+}
 #endif
 }
 qemu_free(block);
@@ -3030,6 +3040,15 @@ void *qemu_get_ram_ptr(ram_addr_t addr)
 QLIST_REMOVE(block, next);
 QLIST_INSERT_HEAD(ram_list.blocks, block, next);
 }
+if (xen_mapcache_enabled()) {
+/* We need to check if the requested address is in the RAM
+ * because we don't want to map the entire memory in QEMU.
+ */
+if (block-offset == 0) {
+return qemu_map_cache(addr, 0, 1);
+}
+block-host = qemu_map_cache(block-offset, block-length, 1);
+}
 return block-host + (addr - block-offset);
 }
 }
@@ -3065,11 +3084,21 @@ int qemu_ram_addr_from_host(void *ptr, ram_addr_t 
*ram_addr)
 uint8_t *host = ptr;
 
 QLIST_FOREACH(block, ram_list.blocks, next) {
+/* This case append when the block is not mapped. */
+if (block-host == NULL) {
+continue;
+}
 if (host - block-host  

[Qemu-devel] [PATCH V12 05/17] xen: Add xenfv machine

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

Introduce the Xen FV (Fully Virtualized) machine to Qemu, some more Xen
specific call will be added in further patches.

Signed-off-by: Anthony PERARD anthony.per...@citrix.com
---
 hw/pc.c  |   19 +--
 hw/pc_piix.c |   17 +
 hw/xen.h |4 
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 6939c04..d7732d4 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -41,6 +41,7 @@
 #include sysemu.h
 #include blockdev.h
 #include ui/qemu-spice.h
+#include xen.h
 
 /* output Bochs bios info messages */
 //#define DEBUG_BIOS
@@ -918,7 +919,11 @@ static void pc_cpu_reset(void *opaque)
 CPUState *env = opaque;
 
 cpu_reset(env);
-env-halted = !cpu_is_bsp(env);
+if (!xen_enabled()) {
+env-halted = !cpu_is_bsp(env);
+} else {
+env-halted = 1;
+}
 }
 
 static CPUState *pc_new_cpu(const char *cpu_model)
@@ -952,7 +957,12 @@ void pc_cpus_init(const char *cpu_model)
 #endif
 }
 
-for(i = 0; i  smp_cpus; i++) {
+if (!xen_enabled()) {
+for(i = 0; i  smp_cpus; i++) {
+pc_new_cpu(cpu_model);
+}
+} else {
+/* Xen require only one Qemu VCPU */
 pc_new_cpu(cpu_model);
 }
 }
@@ -980,6 +990,11 @@ void pc_memory_init(ram_addr_t ram_size,
 *above_4g_mem_size_p = above_4g_mem_size;
 *below_4g_mem_size_p = below_4g_mem_size;
 
+if (xen_enabled()) {
+/* Nothing to do for Xen */
+return;
+}
+
 linux_boot = (kernel_filename != NULL);
 
 /* allocate RAM */
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index b3ede89..6eff06e 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -37,6 +37,10 @@
 #include sysbus.h
 #include arch_init.h
 #include blockdev.h
+#include xen.h
+#ifdef CONFIG_XEN
+#  include xen/hvm/hvm_info_table.h
+#endif
 
 #define MAX_IDE_BUS 2
 
@@ -391,6 +395,16 @@ static QEMUMachine isapc_machine = {
 .max_cpus = 1,
 };
 
+#ifdef CONFIG_XEN
+static QEMUMachine xenfv_machine = {
+.name = xenfv,
+.desc = Xen Fully-virtualized PC,
+.init = pc_init_pci,
+.max_cpus = HVM_MAX_VCPUS,
+.default_machine_opts = accel=xen,
+};
+#endif
+
 static void pc_machine_init(void)
 {
 qemu_register_machine(pc_machine);
@@ -399,6 +413,9 @@ static void pc_machine_init(void)
 qemu_register_machine(pc_machine_v0_11);
 qemu_register_machine(pc_machine_v0_10);
 qemu_register_machine(isapc_machine);
+#ifdef CONFIG_XEN
+qemu_register_machine(xenfv_machine);
+#endif
 }
 
 machine_init(pc_machine_init);
diff --git a/hw/xen.h b/hw/xen.h
index 1fefe3a..726360a 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -31,4 +31,8 @@ static inline int xen_enabled(void)
 
 int xen_init(void);
 
+#if defined(CONFIG_XEN)  CONFIG_XEN_CTRL_INTERFACE_VERSION  400
+#  define HVM_MAX_VCPUS 32
+#endif
+
 #endif /* QEMU_HW_XEN_H */
-- 
1.7.2.3




[Qemu-devel] [PATCH V12 08/17] xen: Introduce Xen Interrupt Controller

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

Every set_irq call makes a Xen hypercall.

Signed-off-by: Anthony PERARD anthony.per...@citrix.com
Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com
---
 hw/pc_piix.c |8 ++--
 hw/xen.h |2 ++
 xen-all.c|   12 
 xen-stub.c   |5 +
 4 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index b9b99d2..7da166d 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -99,8 +99,12 @@ static void pc_init1(ram_addr_t ram_size,
 pc_memory_init(ram_size, kernel_filename, kernel_cmdline, initrd_filename,
below_4g_mem_size, above_4g_mem_size);
 
-cpu_irq = pc_allocate_cpu_irq();
-i8259 = i8259_init(cpu_irq[0]);
+if (!xen_enabled()) {
+cpu_irq = pc_allocate_cpu_irq();
+i8259 = i8259_init(cpu_irq[0]);
+} else {
+i8259 = xen_interrupt_controller_init();
+}
 isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
 isa_irq_state-i8259 = i8259;
 if (pci_enabled) {
diff --git a/hw/xen.h b/hw/xen.h
index 620827d..63d953f 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -35,6 +35,8 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
 void xen_piix3_set_irq(void *opaque, int irq_num, int level);
 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
 
+qemu_irq *xen_interrupt_controller_init(void);
+
 int xen_init(void);
 
 #if defined(CONFIG_XEN)  CONFIG_XEN_CTRL_INTERFACE_VERSION  400
diff --git a/xen-all.c b/xen-all.c
index 0bc0978..22bd413 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -40,6 +40,18 @@ void xen_piix_pci_write_config_client(uint32_t address, 
uint32_t val, int len)
 }
 }
 
+/* Xen Interrupt Controller */
+
+static void xen_set_irq(void *opaque, int irq, int level)
+{
+xc_hvm_set_isa_irq_level(xen_xc, xen_domid, irq, level);
+}
+
+qemu_irq *xen_interrupt_controller_init(void)
+{
+return qemu_allocate_irqs(xen_set_irq, NULL, 16);
+}
+
 /* Initialise Xen */
 
 int xen_init(void)
diff --git a/xen-stub.c b/xen-stub.c
index dc90f10..3a8449c 100644
--- a/xen-stub.c
+++ b/xen-stub.c
@@ -22,6 +22,11 @@ void xen_piix_pci_write_config_client(uint32_t address, 
uint32_t val, int len)
 {
 }
 
+qemu_irq *xen_interrupt_controller_init(void)
+{
+return NULL;
+}
+
 int xen_init(void)
 {
 return -ENOSYS;
-- 
1.7.2.3




[Qemu-devel] [PATCH V12 16/17] xen: Set running state in xenstore.

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

This tells to the xen management tool that the machine can begin run.

Signed-off-by: Anthony PERARD anthony.per...@citrix.com
Acked-by: Alexander Graf ag...@suse.de
---
 xen-all.c |   23 +++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/xen-all.c b/xen-all.c
index 8fabc9d..8167b44 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -63,6 +63,8 @@ typedef struct XenIOState {
 /* which vcpu we are serving */
 int send_vcpu;
 
+struct xs_handle *xenstore;
+
 Notifier exit;
 } XenIOState;
 
@@ -431,6 +433,17 @@ static void cpu_handle_ioreq(void *opaque)
 }
 }
 
+static void xenstore_record_dm_state(XenIOState *s, const char *state)
+{
+char path[50];
+
+snprintf(path, sizeof (path), /local/domain/0/device-model/%u/state, 
xen_domid);
+if (!xs_write(s-xenstore, XBT_NULL, path, state, strlen(state))) {
+fprintf(stderr, error recording dm state\n);
+exit(1);
+}
+}
+
 static void xen_main_loop_prepare(XenIOState *state)
 {
 int evtchn_fd = -1;
@@ -446,6 +459,9 @@ static void xen_main_loop_prepare(XenIOState *state)
 if (evtchn_fd != -1) {
 qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, state);
 }
+
+/* record state running */
+xenstore_record_dm_state(state, running);
 }
 
 
@@ -464,6 +480,7 @@ static void xen_exit_notifier(Notifier *n)
 XenIOState *state = container_of(n, XenIOState, exit);
 
 xc_evtchn_close(state-xce_handle);
+xs_daemon_close(state-xenstore);
 }
 
 int xen_init(void)
@@ -486,6 +503,12 @@ int xen_init(void)
 return -errno;
 }
 
+state-xenstore = xs_daemon_open();
+if (state-xenstore == NULL) {
+perror(xen: xenstore open);
+return -errno;
+}
+
 state-exit.notify = xen_exit_notifier;
 qemu_add_exit_notifier(state-exit);
 
-- 
1.7.2.3




[Qemu-devel] [PATCH V12 12/17] Introduce qemu_put_ram_ptr

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

This function allows to unlock a ram_ptr give by qemu_get_ram_ptr. After
a call to qemu_put_ram_ptr, the pointer may be unmap from QEMU when
used with Xen.

Signed-off-by: Anthony PERARD anthony.per...@citrix.com
Acked-by: Alexander Graf ag...@suse.de
---
 cpu-common.h   |1 +
 exec.c |   10 ++
 xen-mapcache.c |   34 ++
 3 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/cpu-common.h b/cpu-common.h
index ef4e8da..6863b57 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -56,6 +56,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr);
 /* Same but slower, to use for migration, where the order of
  * RAMBlocks must not change. */
 void *qemu_safe_ram_ptr(ram_addr_t addr);
+void qemu_put_ram_ptr(void *addr);
 /* This should not be used by devices.  */
 int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr);
 ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr);
diff --git a/exec.c b/exec.c
index 941abce..9301ba3 100644
--- a/exec.c
+++ b/exec.c
@@ -3078,6 +3078,13 @@ void *qemu_safe_ram_ptr(ram_addr_t addr)
 return NULL;
 }
 
+void qemu_put_ram_ptr(void *addr)
+{
+if (xen_mapcache_enabled()) {
+qemu_map_cache_unlock(addr);
+}
+}
+
 int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)
 {
 RAMBlock *block;
@@ -3793,6 +3800,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, 
uint8_t *buf,
 cpu_physical_memory_set_dirty_flags(
 addr1, (0xff  ~CODE_DIRTY_FLAG));
 }
+qemu_put_ram_ptr(ptr);
 }
 } else {
 if ((pd  ~TARGET_PAGE_MASK)  IO_MEM_ROM 
@@ -3823,6 +3831,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, 
uint8_t *buf,
 ptr = qemu_get_ram_ptr(pd  TARGET_PAGE_MASK) +
 (addr  ~TARGET_PAGE_MASK);
 memcpy(buf, ptr, l);
+qemu_put_ram_ptr(ptr);
 }
 }
 len -= l;
@@ -3863,6 +3872,7 @@ void cpu_physical_memory_write_rom(target_phys_addr_t 
addr,
 /* ROM/RAM case */
 ptr = qemu_get_ram_ptr(addr1);
 memcpy(ptr, buf, l);
+qemu_put_ram_ptr(ptr);
 }
 len -= l;
 buf += l;
diff --git a/xen-mapcache.c b/xen-mapcache.c
index eab97bc..0142c09 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -194,6 +194,40 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, 
target_phys_addr_t size, u
 return mapcache-last_address_vaddr + address_offset;
 }
 
+void qemu_map_cache_unlock(void *buffer)
+{
+MapCacheEntry *entry = NULL, *pentry = NULL;
+MapCacheRev *reventry;
+target_phys_addr_t paddr_index;
+int found = 0;
+
+QTAILQ_FOREACH(reventry, mapcache-locked_entries, next) {
+if (reventry-vaddr_req == buffer) {
+paddr_index = reventry-paddr_index;
+found = 1;
+break;
+}
+}
+if (!found) {
+return;
+}
+QTAILQ_REMOVE(mapcache-locked_entries, reventry, next);
+qemu_free(reventry);
+
+entry = mapcache-entry[paddr_index % mapcache-nr_buckets];
+while (entry  entry-paddr_index != paddr_index) {
+pentry = entry;
+entry = entry-next;
+}
+if (!entry) {
+return;
+}
+entry-lock--;
+if (entry-lock  0) {
+entry-lock--;
+}
+}
+
 ram_addr_t qemu_ram_addr_from_mapcache(void *ptr)
 {
 MapCacheRev *reventry;
-- 
1.7.2.3




[Qemu-devel] [PATCH V12 11/17] configure: Always use 64bits target physical addresses with xen enabled.

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

With MapCache, we can handle a 64b target, even with a 32b host/qemu.
So, we need to have target_phys_addr_t to 64bits.

Signed-off-by: Anthony PERARD anthony.per...@citrix.com
Acked-by: Alexander Graf ag...@suse.de
---
 configure |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 309b210..34248f0 100755
--- a/configure
+++ b/configure
@@ -3190,6 +3190,7 @@ echo TARGET_ABI_DIR=$TARGET_ABI_DIR  
$config_target_mak
 case $target_arch2 in
   i386|x86_64)
 if test $xen = yes -a $target_softmmu = yes ; then
+  target_phys_bits=64
   echo CONFIG_XEN=y  $config_target_mak
   if test $cpu = i386 -o $cpu = x86_64; then
   echo CONFIG_XEN_MAPCACHE=y  $config_target_mak
-- 
1.7.2.3




[Qemu-devel] [PATCH V12 15/17] xen: Initialize event channels and io rings

2011-03-29 Thread anthony . perard
From: Arun Sharma arun.sha...@intel.com

Open and bind event channels; map ioreq and buffered ioreq rings.

Signed-off-by: Arun Sharma arun.sha...@intel.com
Signed-off-by: Anthony PERARD anthony.per...@citrix.com
Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com
Acked-by: Alexander Graf ag...@suse.de
---
 hw/xen_common.h |2 +
 xen-all.c   |  419 +++
 2 files changed, 421 insertions(+), 0 deletions(-)

diff --git a/hw/xen_common.h b/hw/xen_common.h
index dd3e896..a1958a0 100644
--- a/hw/xen_common.h
+++ b/hw/xen_common.h
@@ -107,4 +107,6 @@ static inline int xc_fd(xc_interface *xen_xc)
 }
 #endif
 
+void destroy_hvm_domain(void);
+
 #endif /* QEMU_HW_XEN_COMMON_H */
diff --git a/xen-all.c b/xen-all.c
index dac545b..8fabc9d 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -6,12 +6,66 @@
  *
  */
 
+#include sys/mman.h
+
 #include hw/pci.h
 #include hw/xen_common.h
 #include hw/xen_backend.h
 
 #include xen-mapcache.h
 
+#include xen/hvm/ioreq.h
+#include xen/hvm/params.h
+
+//#define DEBUG_XEN
+
+#ifdef DEBUG_XEN
+#define DPRINTF(fmt, ...) \
+do { fprintf(stderr, xen:  fmt, ## __VA_ARGS__); } while (0)
+#else
+#define DPRINTF(fmt, ...) \
+do { } while (0)
+#endif
+
+/* Compatibility with older version */
+#if __XEN_LATEST_INTERFACE_VERSION__  0x0003020a
+static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i)
+{
+return shared_page-vcpu_iodata[i].vp_eport;
+}
+static inline ioreq_t *xen_vcpu_ioreq(shared_iopage_t *shared_page, int vcpu)
+{
+return shared_page-vcpu_iodata[vcpu].vp_ioreq;
+}
+#  define FMT_ioreq_size PRIx64
+#else
+static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i)
+{
+return shared_page-vcpu_ioreq[i].vp_eport;
+}
+static inline ioreq_t *xen_vcpu_ioreq(shared_iopage_t *shared_page, int vcpu)
+{
+return shared_page-vcpu_ioreq[vcpu];
+}
+#  define FMT_ioreq_size u
+#endif
+
+#define BUFFER_IO_MAX_DELAY  100
+
+typedef struct XenIOState {
+shared_iopage_t *shared_page;
+buffered_iopage_t *buffered_io_page;
+QEMUTimer *buffered_io_timer;
+/* the evtchn port for polling the notification, */
+evtchn_port_t *ioreq_local_port;
+/* the evtchn fd for polling */
+XenEvtchn xce_handle;
+/* which vcpu we are serving */
+int send_vcpu;
+
+Notifier exit;
+} XenIOState;
+
 /* Xen specific function for piix pci */
 
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
@@ -112,19 +166,384 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size)
 }
 
 
+/* VCPU Operations, MMIO, IO ring ... */
+
+/* get the ioreq packets from share mem */
+static ioreq_t *cpu_get_ioreq_from_shared_memory(XenIOState *state, int vcpu)
+{
+ioreq_t *req = xen_vcpu_ioreq(state-shared_page, vcpu);
+
+if (req-state != STATE_IOREQ_READY) {
+DPRINTF(I/O request not ready: 
+%x, ptr: %x, port: %PRIx64, 
+data: %PRIx64, count: % FMT_ioreq_size , size: % 
FMT_ioreq_size \n,
+req-state, req-data_is_ptr, req-addr,
+req-data, req-count, req-size);
+return NULL;
+}
+
+xen_rmb(); /* see IOREQ_READY /then/ read contents of ioreq */
+
+req-state = STATE_IOREQ_INPROCESS;
+return req;
+}
+
+/* use poll to get the port notification */
+/* ioreq_vec--out,the */
+/* retval--the number of ioreq packet */
+static ioreq_t *cpu_get_ioreq(XenIOState *state)
+{
+int i;
+evtchn_port_t port;
+
+port = xc_evtchn_pending(state-xce_handle);
+if (port != -1) {
+for (i = 0; i  smp_cpus; i++) {
+if (state-ioreq_local_port[i] == port) {
+break;
+}
+}
+
+if (i == smp_cpus) {
+hw_error(Fatal error while trying to get io event!\n);
+}
+
+/* unmask the wanted port again */
+xc_evtchn_unmask(state-xce_handle, port);
+
+/* get the io packet from shared memory */
+state-send_vcpu = i;
+return cpu_get_ioreq_from_shared_memory(state, i);
+}
+
+/* read error or read nothing */
+return NULL;
+}
+
+static uint32_t do_inp(pio_addr_t addr, unsigned long size)
+{
+switch (size) {
+case 1:
+return cpu_inb(addr);
+case 2:
+return cpu_inw(addr);
+case 4:
+return cpu_inl(addr);
+default:
+hw_error(inp: bad size: %04FMT_pioaddr %lx, addr, size);
+}
+}
+
+static void do_outp(pio_addr_t addr,
+unsigned long size, uint32_t val)
+{
+switch (size) {
+case 1:
+return cpu_outb(addr, val);
+case 2:
+return cpu_outw(addr, val);
+case 4:
+return cpu_outl(addr, val);
+default:
+hw_error(outp: bad size: %04FMT_pioaddr %lx, addr, size);
+}
+}
+
+static void cpu_ioreq_pio(ioreq_t *req)
+{
+int i, sign;
+
+sign = req-df ? -1 : 1;
+
+if (req-dir == IOREQ_READ) {
+if 

[Qemu-devel] [PATCH V12 10/17] xen: Adds a cap to the number of map cache entries.

2011-03-29 Thread anthony . perard
From: John Baboval john.babo...@virtualcomputer.com

Adds a cap to the number of map cache entries. This prevents the map
cache from overwhelming system memory.

I also removed the bitmap macros and #included bitmap.h instead.

Signed-off-By: John Baboval john.babo...@virtualcomputer.com
Signed-off-by: Anthony PERARD anthony.per...@citrix.com
---
 xen-mapcache.c |   21 ++---
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/xen-mapcache.c b/xen-mapcache.c
index d7f44a7..eab97bc 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -12,6 +12,7 @@
 
 #include hw/xen_backend.h
 #include blockdev.h
+#include bitmap.h
 
 #include xen/hvm/params.h
 #include sys/mman.h
@@ -31,15 +32,13 @@
 
 #if defined(__i386__)
 #  define MCACHE_BUCKET_SHIFT 16
+#  define MCACHE_MAX_SIZE (1UL31) /* 2GB Cap */
 #elif defined(__x86_64__)
 #  define MCACHE_BUCKET_SHIFT 20
+#  define MCACHE_MAX_SIZE (1UL35) /* 32GB Cap */
 #endif
 #define MCACHE_BUCKET_SIZE (1UL  MCACHE_BUCKET_SHIFT)
 
-#define BITS_PER_LONG (sizeof(long) * 8)
-#define BITS_TO_LONGS(bits) (((bits) + BITS_PER_LONG - 1) / BITS_PER_LONG)
-#define DECLARE_BITMAP(name, bits) unsigned long name[BITS_TO_LONGS(bits)]
-
 typedef struct MapCacheEntry {
 target_phys_addr_t paddr_index;
 uint8_t *vaddr_base;
@@ -68,11 +67,6 @@ typedef struct MapCache {
 
 static MapCache *mapcache;
 
-static inline int test_bit(unsigned int bit, const unsigned long *map)
-{
-return !!((map)[(bit) / BITS_PER_LONG]  (1UL  ((bit) % BITS_PER_LONG)));
-}
-
 void qemu_map_cache_init(void)
 {
 unsigned long size;
@@ -84,9 +78,14 @@ void qemu_map_cache_init(void)
 mapcache-last_address_index = -1;
 
 getrlimit(RLIMIT_AS, rlimit_as);
-rlimit_as.rlim_cur = rlimit_as.rlim_max;
+if (rlimit_as.rlim_max  MCACHE_MAX_SIZE) {
+rlimit_as.rlim_cur = rlimit_as.rlim_max;
+} else {
+rlimit_as.rlim_cur = MCACHE_MAX_SIZE;
+}
+
 setrlimit(RLIMIT_AS, rlimit_as);
-mapcache-max_mcache_size = rlimit_as.rlim_max;
+mapcache-max_mcache_size = rlimit_as.rlim_cur;
 
 mapcache-nr_buckets =
 (((mapcache-max_mcache_size  XC_PAGE_SHIFT) +
-- 
1.7.2.3




[Qemu-devel] [PATCH V12 17/17] xen: Add Xen hypercall for sleep state in the cmos_s3 callback.

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

Signed-off-by: Anthony PERARD anthony.per...@citrix.com
---
 hw/pc_piix.c |6 +-
 hw/xen.h |1 +
 xen-all.c|9 +
 xen-stub.c   |4 
 4 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 7da166d..d5e7484 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -181,7 +181,11 @@ static void pc_init1(ram_addr_t ram_size,
 uint8_t *eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this 
persistent */
 i2c_bus *smbus;
 
-cmos_s3 = qemu_allocate_irqs(pc_cmos_set_s3_resume, rtc_state, 1);
+if (!xen_enabled()) {
+cmos_s3 = qemu_allocate_irqs(pc_cmos_set_s3_resume, rtc_state, 1);
+} else {
+cmos_s3 = qemu_allocate_irqs(xen_cmos_set_s3_resume, rtc_state, 1);
+}
 smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
 /* TODO: Populate SPD eeprom data.  */
 smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
diff --git a/hw/xen.h b/hw/xen.h
index 9b625fd..adc32f7 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -43,6 +43,7 @@ static inline int xen_mapcache_enabled(void)
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
 void xen_piix3_set_irq(void *opaque, int irq_num, int level);
 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
+void xen_cmos_set_s3_resume(void *opaque, int irq, int level);
 
 qemu_irq *xen_interrupt_controller_init(void);
 
diff --git a/xen-all.c b/xen-all.c
index 8167b44..12258ef 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -9,6 +9,7 @@
 #include sys/mman.h
 
 #include hw/pci.h
+#include hw/pc.h
 #include hw/xen_common.h
 #include hw/xen_backend.h
 
@@ -98,6 +99,14 @@ void xen_piix_pci_write_config_client(uint32_t address, 
uint32_t val, int len)
 }
 }
 
+void xen_cmos_set_s3_resume(void *opaque, int irq, int level)
+{
+pc_cmos_set_s3_resume(opaque, irq, level);
+if (level) {
+xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 3);
+}
+}
+
 /* Xen Interrupt Controller */
 
 static void xen_set_irq(void *opaque, int irq, int level)
diff --git a/xen-stub.c b/xen-stub.c
index 8d2fa54..a4f35a1 100644
--- a/xen-stub.c
+++ b/xen-stub.c
@@ -22,6 +22,10 @@ void xen_piix_pci_write_config_client(uint32_t address, 
uint32_t val, int len)
 {
 }
 
+void xen_cmos_set_s3_resume(void *opaque, int irq, int level)
+{
+}
+
 void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size)
 {
 }
-- 
1.7.2.3




[Qemu-devel] [PATCH V12 14/17] vl.c: Introduce getter for shutdown_requested and reset_requested.

2011-03-29 Thread anthony . perard
From: Anthony PERARD anthony.per...@citrix.com

Introduce two functions qemu_shutdown_requested_get and
qemu_reset_requested_get to get the value of shutdown/reset_requested
without reset it.

Signed-off-by: Anthony PERARD anthony.per...@citrix.com
Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com
Acked-by: Alexander Graf ag...@suse.de
---
 sysemu.h |2 ++
 vl.c |   10 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/sysemu.h b/sysemu.h
index bbbd0fd..3d4be78 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -63,6 +63,8 @@ void qemu_system_shutdown_request(void);
 void qemu_system_powerdown_request(void);
 void qemu_system_debug_request(void);
 void qemu_system_vmstop_request(int reason);
+int qemu_shutdown_requested_get(void);
+int qemu_reset_requested_get(void);
 int qemu_shutdown_requested(void);
 int qemu_reset_requested(void);
 int qemu_powerdown_requested(void);
diff --git a/vl.c b/vl.c
index 5ba1eb9..60ec6de 100644
--- a/vl.c
+++ b/vl.c
@@ -1223,6 +1223,16 @@ static int powerdown_requested;
 static int debug_requested;
 static int vmstop_requested;
 
+int qemu_shutdown_requested_get(void)
+{
+return shutdown_requested;
+}
+
+int qemu_reset_requested_get(void)
+{
+return reset_requested;
+}
+
 int qemu_shutdown_requested(void)
 {
 int r = shutdown_requested;
-- 
1.7.2.3




[Qemu-devel] [PATCH V12 13/17] pci: Use of qemu_put_ram_ptr in pci_add_option_rom.

2011-03-29 Thread anthony . perard
From: John Baboval john.babo...@virtualcomputer.com

Prevent a deadlock caused by leaving a map cache bucket locked by the
preceding qemu_get_ram_ptr() call.

Signed-off-By: John Baboval john.babo...@virtualcomputer.com
Signed-off-by: Anthony PERARD anthony.per...@citrix.com
---
 hw/pci.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 6b577e1..2b24dd4 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1897,6 +1897,8 @@ static int pci_add_option_rom(PCIDevice *pdev, bool 
is_default_rom)
 pci_patch_ids(pdev, ptr, size);
 }
 
+qemu_put_ram_ptr(ptr);
+
 pci_register_bar(pdev, PCI_ROM_SLOT, size,
  0, pci_map_option_rom);
 
-- 
1.7.2.3




[Qemu-devel] [PATCH v2 2/3] block: Do not cache device size for removable media

2011-03-29 Thread Stefan Hajnoczi
The block layer caches the device size to avoid doing lseek(fd, 0,
SEEK_END) every time this value is needed.  For removable media the
device size becomes stale if a new medium is inserted.  This patch
simply prevents device size caching for removable media.

A smarter solution is to update the cached device size when a new medium
is inserted.  Given that there are currently bugs with CD-ROM media
change I do not want to implement that approach until we've gotten
things correct first.

Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
---
 block.c |   12 +---
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/block.c b/block.c
index f812c20..2bd353f 100644
--- a/block.c
+++ b/block.c
@@ -1153,14 +1153,12 @@ int64_t bdrv_getlength(BlockDriverState *bs)
 if (!drv)
 return -ENOMEDIUM;
 
-/* Fixed size devices use the total_sectors value for speed instead of
-   issuing a length query (like lseek) on each call.  Also, legacy block
-   drivers don't provide a bdrv_getlength function and must use
-   total_sectors. */
-if (!bs-growable || !drv-bdrv_getlength) {
-return bs-total_sectors * BDRV_SECTOR_SIZE;
-}
-return drv-bdrv_getlength(bs);
+if (bs-growable || bs-removable) {
+if (drv-bdrv_getlength) {
+return drv-bdrv_getlength(bs);
+}
+}
+return bs-total_sectors * BDRV_SECTOR_SIZE;
 }
 
 /* return 0 as number of sectors if no device present or error */
-- 
1.7.4.1




[Qemu-devel] [PATCH v2 0/3] block: Correct size across CD-ROM media change

2011-03-29 Thread Stefan Hajnoczi
This patch series fixes two Linux host CD-ROM pass-through bugs in QEMU.

After applying these patches it is possible to pass-through a Linux host CD-ROM
completely.  The guest can eject from software or the physical eject button can
be pressed on the drive.  The guest can detect this and newly inserted media
are noticed.  There is no need to issue any QEMU monitor 'eject' or 'change'
commands because the host CD-ROM is completely passed through.

Patch details:

The first is that the device size is cached even for removable devices and we
never update it.  If a host CD-ROM is changed, then the size will be stale and
reflect that of the last medium.

The second is that Linux host CD-ROM pass-through requires that we re-open the
device to refresh its size.  This is because the Linux CD-ROM driver only
refreshes the size when the device is opened and furthermore has a bug that
leads to stale sizes if the file descriptor is held across media change.

I have also included a trace event for bdrv_set_locked() because it is useful
information when debugging issues like these in the future.

v2:
 * Clarify cdrom_is_inserted() comment as per Juan's suggestion




[Qemu-devel] [PATCH v2 3/3] raw-posix: Re-open host CD-ROM after media change

2011-03-29 Thread Stefan Hajnoczi
Piggy-back on the guest CD-ROM polling to poll on the host.  Open and
close the host CD-ROM file descriptor to ensure we read the new size and
not a stale size.

Two things are going on here:

1. If hald/udisks is not already polling CD-ROMs on the host then
   re-opening the CD-ROM causes the host to read the new medium's size.

2. There is a bug in Linux which means the CD-ROM file descriptor must
   be re-opened in order for lseek(2) to see the new size.  The
   inode size gets out of sync with the underlying device (which you can
   confirm by checking that /sys/block/sr0/size and lseek(2) do not
   match after media change).  I have raised this with the
   maintainers but we need a workaround for the foreseeable future.

Note that these changes are all in a #ifdef __linux__ section.

Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
---
 block/raw-posix.c |   26 ++
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 6b72470..8b5205c 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1238,10 +1238,28 @@ static int cdrom_is_inserted(BlockDriverState *bs)
 BDRVRawState *s = bs-opaque;
 int ret;
 
-ret = ioctl(s-fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
-if (ret == CDS_DISC_OK)
-return 1;
-return 0;
+/*
+ * Close the file descriptor if no medium is present and open it to poll
+ * again.  This ensures the medium size is refreshed.  If the file
+ * descriptor is kept open the size can become stale.  This is essentially
+ * replicating CD-ROM polling but is driven by the guest.  As the guest
+ * polls, we poll the host.
+ */
+
+if (s-fd == -1) {
+s-fd = qemu_open(bs-filename, s-open_flags, 0644);
+if (s-fd  0) {
+return 0;
+}
+}
+
+ret = (ioctl(s-fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK);
+
+if (!ret) {
+close(s-fd);
+s-fd = -1;
+}
+return ret;
 }
 
 static int cdrom_eject(BlockDriverState *bs, int eject_flag)
-- 
1.7.4.1




[Qemu-devel] [PATCH v2 1/3] trace: Trace bdrv_set_locked()

2011-03-29 Thread Stefan Hajnoczi
It can be handy to know when the guest locks/unlocks the CD-ROM tray.
This trace event makes that possible.

Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
---
 block.c  |2 ++
 trace-events |1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/block.c b/block.c
index c8e2f97..f812c20 100644
--- a/block.c
+++ b/block.c
@@ -2809,6 +2809,8 @@ void bdrv_set_locked(BlockDriverState *bs, int locked)
 {
 BlockDriver *drv = bs-drv;
 
+trace_bdrv_set_locked(bs, locked);
+
 bs-locked = locked;
 if (drv  drv-bdrv_set_locked) {
 drv-bdrv_set_locked(bs, locked);
diff --git a/trace-events b/trace-events
index 90c9e0b..3267df3 100644
--- a/trace-events
+++ b/trace-events
@@ -54,6 +54,7 @@ disable bdrv_aio_multiwrite_latefail(void *mcb, int i) mcb 
%p i %d
 disable bdrv_aio_flush(void *bs, void *opaque) bs %p opaque %p
 disable bdrv_aio_readv(void *bs, int64_t sector_num, int nb_sectors, void 
*opaque) bs %p sector_num %PRId64 nb_sectors %d opaque %p
 disable bdrv_aio_writev(void *bs, int64_t sector_num, int nb_sectors, void 
*opaque) bs %p sector_num %PRId64 nb_sectors %d opaque %p
+disable bdrv_set_locked(void *bs, int locked) bs %p locked %d
 
 # hw/virtio-blk.c
 disable virtio_blk_req_complete(void *req, int status) req %p status %d
-- 
1.7.4.1




Re: [Qemu-devel] QEMU development for MIPS64 user mode

2011-03-29 Thread Andreas Färber

Hi,

Am 29.03.2011 um 08:49 schrieb Khansa Butt:

I have added support for MIPS64 user mode emulation in QEMU and  
email git patch to the qemu-devel mailing list
but I got no any response yet. My Patch mail has the following  
subject line

MIPS64 user mode emulation Patch
please verify that this patch mail is not neglected or guide me  
towards the proper way of patch submitting.


You should use git-send-email to submit it (marking it as [PATCH]) so  
that it can be applied with git-am, see http://wiki.qemu.org/Contribute/SubmitAPatch 
 and the list archives.
Also don't forget to cc the maintainer(s) - Aurelien for mips and Riku  
for linux-user IIRC.


A description of how to test it may be helpful. Maybe you have links  
to mips64 binaries that work?


Usually, the subject line of the commit message is prefixed with the  
topic (linux-user) or architecture (mips).
If all the people you name contributed to this patch, you should  
probably add their SoBs before yours.
The patch is rather large - is it possible to split it up into a patch  
series with at least a linux-user and a (target-)mips part?


TARGET_OCTEON looks rather uncommon to me...

Your patch contains a Nasty hack. Please elaborate on that - what's  
the problem, do you intend to fix it later, etc.


You simply comment out a #warning that signal handling is not  
implemented for mipsn64. Why didn't you implement it? Don't you need it?
Similarly you comment out a sign extension. Please elaborate. If it's  
a bug and definitely wrong, it should be moved to its own patch,  
explaining what goes wrong and fully removing it instead.


In CPUMIPSState, the surrounding struct members use lowercase  
characters.


Some spaces missing after if.

Thanks for your contribution and for taking the time to go through the  
review process.


Regards,
Andreas



  1   2   >