Re: [Qemu-devel] qemu-ppc can't run static uClibc binaries.

2010-02-14 Thread Rob Landley
On Thursday 11 February 2010 06:32:12 Alexander Graf wrote:
 Rob Landley wrote:
  Static binaries that run under the Linux kernel don't run under qemu-ppc.
   For example, the prebuilt busybox binaries here:
 
http://busybox.net/downloads/binaries/1.16.0/busybox-powerpc
 
  Don't run under qemu-ppc, but runs just fine under qemu-system-ppc with
  the image at:
 
   
  http://impactlinux.com/fwl/downloads/binaries/system-image-powerpc.tar.bz
 2
 
  The reason is that the powerpc spec that qemu was written to is for
  AIX, not for Linux, and thus the register layout qemu application
  emulation provides for powerpc doesn't match what the kernel is actually
  doing.
 
  For dynamically linked executables, the dynamic linker reorganizes the
  register contents to match the AIX spec from IBM, but statically linked
  binaries get what the kernel provides directly.  Thus binaries statically
  linked against uClibc won't run under qemu-ppc, but run under
  qemu-system-ppc just fine.
 
  I tracked down this problem in 2007:
 
http://landley.net/notes-2007.html#28-03-2007
 
  And reported it on the list at the time:
 
http://lists.gnu.org/archive/html/qemu-devel/2007-03/msg00713.html
http://lists.gnu.org/archive/html/qemu-devel/2007-03/msg00720.html
http://lists.gnu.org/archive/html/qemu-devel/2007-04/msg00315.html
 
  However, the then-maintainer of powerpc believed nobody else ever had the
  right to touch her code:
 
http://lists.gnu.org/archive/html/qemu-devel/2007-04/msg00198.html
 
  And I was unable to convince her that insisting reality change to match a
  spec which wasn't even for the right platform was not a useful approach. 
  Thus the binary in the first link still won't run under qemu-ppc three
  years later, despite running fine under a real Linux kernel.

 Patches are always welcome. The only thing you might want to make sure
 is that dynamically linked binaries also still continue to work :-).

Attached.

This may help explain the issue:

  http://sources.redhat.com/ml/libc-alpha/2003-03/msg00272.html

It's not a question of dynamically linked Linux binaries.  They work just fine 
with either register layout.  The dynamic linker converts the Linux layout to 
the AIX layout, and is reentrant so it won't do it a second time if it's 
already been converted.

The problem is that BSD wants the AIX layout, and hence this comment in linux-
user/elfload.c function init_thread():

/* Note that isn't exactly what regular kernel does
 * but this is what the ABI wants and is needed to allow
 * execution of PPC BSD programs.
 */

I.E. whoever wrote this already knows it's not what the Linux kernel is 
actually doing, and they're not doing it for Linux, they're doing it for BSD.

The fix is probably to add #ifdef CONFIG_BSD around the appropriate chunk of 
code.  Attached is a patch to do that (plus tweaks to make the you have an 
unused variable, break the build! logic shut up about it).

(Yes, I tested that a dynamically linked hello world still worked for me.)

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 1d5f651..eaabdac 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -513,12 +513,11 @@ do {\
 static inline void init_thread(struct target_pt_regs *_regs, struct image_info *infop)
 {
 abi_ulong pos = infop-start_stack;
-abi_ulong tmp;
 #if defined(TARGET_PPC64)  !defined(TARGET_ABI32)
 abi_ulong entry, toc;
 #endif
 
-_regs-gpr[1] = infop-start_stack;
+_regs-gpr[1] = pos;
 #if defined(TARGET_PPC64)  !defined(TARGET_ABI32)
 entry = ldq_raw(infop-entry) + infop-load_addr;
 toc = ldq_raw(infop-entry + 8) + infop-load_addr;
@@ -526,6 +525,8 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info *
 infop-entry = entry;
 #endif
 _regs-nip = infop-entry;
+
+#if defined(CONFIG_BSD)
 /* Note that isn't exactly what regular kernel does
  * but this is what the ABI wants and is needed to allow
  * execution of PPC BSD programs.
@@ -534,9 +535,13 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info *
 get_user_ual(_regs-gpr[3], pos);
 pos += sizeof(abi_ulong);
 _regs-gpr[4] = pos;
-for (tmp = 1; tmp != 0; pos += sizeof(abi_ulong))
-tmp = ldl(pos);
+for (;;) {
+abi_ulong tmp = pos;
+pos += sizeof(abi_ulong);
+if (!ldl(tmp)) break;
+}
 _regs-gpr[5] = pos;
+#endif
 }
 
 /* See linux kernel: arch/powerpc/include/asm/elf.h.  */


[Qemu-devel] [PATCH v4 rebased] block: more read-only changes, related to backing files

2010-02-14 Thread Naphtali Sprei
Open backing file read-only where possible
Upgrade backing file to read-write during commit, back to read-only after commit
  If upgrade fail, back to read-only. If also fail, disconnect the drive.

Signed-off-by: Naphtali Sprei nsp...@redhat.com
---
 block.c |   83 ++
 block_int.h |2 +
 2 files changed, 73 insertions(+), 12 deletions(-)

diff --git a/block.c b/block.c
index af56ea7..31d1ba4 100644
--- a/block.c
+++ b/block.c
@@ -363,6 +363,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, 
int flags,
 bs-is_temporary = 0;
 bs-encrypted = 0;
 bs-valid_key = 0;
+bs-open_flags = flags;
 /* buffer_alignment defaulted to 512, drivers can change this value */
 bs-buffer_alignment = 512;
 
@@ -450,8 +451,6 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, 
int flags,
 if (flags  (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))
 bs-enable_write_cache = 1;
 
-bs-read_only = (flags  BDRV_O_RDWR) == 0;
-
 /*
  * Clear flags that are internal to the block layer before opening the
  * image.
@@ -472,6 +471,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, 
int flags,
 goto free_and_fail;
 }
 
+bs-keep_read_only = bs-read_only = !(open_flags  BDRV_O_RDWR);
 if (drv-bdrv_getlength) {
 bs-total_sectors = bdrv_getlength(bs)  BDRV_SECTOR_BITS;
 }
@@ -488,13 +488,22 @@ int bdrv_open2(BlockDriverState *bs, const char 
*filename, int flags,
  filename, bs-backing_file);
 if (bs-backing_format[0] != '\0')
 back_drv = bdrv_find_format(bs-backing_format);
+
+/* backing files always opened read-only */
+open_flags = ~BDRV_O_RDWR;
+
 ret = bdrv_open2(bs-backing_hd, backing_filename, open_flags,
  back_drv);
-bs-backing_hd-read_only =  (open_flags  BDRV_O_RDWR) == 0;
 if (ret  0) {
 bdrv_close(bs);
 return ret;
 }
+if (bs-is_temporary) {
+bs-backing_hd-keep_read_only = !(flags  BDRV_O_RDWR);
+} else {
+/* base image inherits from parent */
+bs-backing_hd-keep_read_only = bs-keep_read_only;
+}
 }
 
 if (!bdrv_key_required(bs)) {
@@ -570,19 +579,48 @@ int bdrv_commit(BlockDriverState *bs)
 {
 BlockDriver *drv = bs-drv;
 int64_t i, total_sectors;
-int n, j;
-int ret = 0;
+int n, j, ro, open_flags;
+int ret = 0, rw_ret = 0;
 unsigned char sector[512];
+char filename[1024];
+BlockDriverState *bs_rw, *bs_ro;
 
 if (!drv)
 return -ENOMEDIUM;
-
-if (bs-read_only) {
-   return -EACCES;
+
+if (!bs-backing_hd) {
+return -ENOTSUP;
 }
 
-if (!bs-backing_hd) {
-   return -ENOTSUP;
+if (bs-backing_hd-keep_read_only) {
+return -EACCES;
+}
+
+ro = bs-backing_hd-read_only;
+strncpy(filename, bs-backing_hd-filename, sizeof(filename));
+open_flags =  bs-backing_hd-open_flags;
+
+if (ro) {
+/* re-open as RW */
+bdrv_delete(bs-backing_hd);
+bs-backing_hd = NULL;
+bs_rw = bdrv_new();
+rw_ret = bdrv_open2(bs_rw, filename, open_flags | BDRV_O_RDWR, NULL);
+if (rw_ret  0) {
+bdrv_delete(bs_rw);
+/* try to re-open read-only */
+bs_ro = bdrv_new();
+ret = bdrv_open2(bs_ro, filename, open_flags  ~BDRV_O_RDWR, NULL);
+if (ret  0) {
+bdrv_delete(bs_ro);
+/* drive not functional anymore */
+bs-drv = NULL;
+return ret;
+}
+bs-backing_hd = bs_ro;
+return rw_ret;
+}
+bs-backing_hd = bs_rw;
 }
 
 total_sectors = bdrv_getlength(bs)  BDRV_SECTOR_BITS;
@@ -590,11 +628,13 @@ int bdrv_commit(BlockDriverState *bs)
 if (drv-bdrv_is_allocated(bs, i, 65536, n)) {
 for(j = 0; j  n; j++) {
 if (bdrv_read(bs, i, sector, 1) != 0) {
-return -EIO;
+ret = -EIO;
+goto ro_cleanup;
 }
 
 if (bdrv_write(bs-backing_hd, i, sector, 1) != 0) {
-return -EIO;
+ret = -EIO;
+goto ro_cleanup;
 }
 i++;
}
@@ -614,6 +654,25 @@ int bdrv_commit(BlockDriverState *bs)
  */
 if (bs-backing_hd)
 bdrv_flush(bs-backing_hd);
+
+ro_cleanup:
+
+if (ro) {
+/* re-open as RO */
+bdrv_delete(bs-backing_hd);
+bs-backing_hd = NULL;
+bs_ro = bdrv_new();
+ret = bdrv_open2(bs_ro, filename, open_flags  ~BDRV_O_RDWR, NULL);
+if (ret  0) {
+bdrv_delete(bs_ro);
+/* drive not functional anymore */
+bs-drv = NULL;
+return ret;
+}
+

[Qemu-devel] Re: [PATCH] Give sdl-config higher priority than pkg-config

2010-02-14 Thread Paolo Bonzini

On 02/14/2010 08:23 AM, Blue Swirl wrote:

On OpenBSD, pkg-config sdl --cflags forgets to add -I/usr/local/include
which is needed for iconv.h (included from SDL.h). This makes SDL
detection fail.

Try sdl-config first, only if it fails try pkg-config.


This breaks cross-compilation.  I'm CCing the OpenBSD package maintainer 
so that he can fix it.


Upstream SDL has

--cflags)
  echo -...@includedir@/SDL @SDL_CFLAGS@
  ;;

in sdl-config.in and

Cflags: -I${includedir}/SDL @SDL_CFLAGS@

in sdl.pc.in, while OpenBSD has different values, so he modified 
sdl-config apparently but not sdl.pc.in.


Paolo




[Qemu-devel] Re: [PATCH 0/4] qemu-kvm: prepare for adding eventfd usage to upstream

2010-02-14 Thread Avi Kivity

On 02/13/2010 03:26 PM, Marcelo Tosatti wrote:

On Thu, Feb 11, 2010 at 12:09:12AM +0100, Paolo Bonzini wrote:
   

This patch series morphs the code in qemu-kvm's eventfd so that it looks
like the code in upstream qemu.  Patch 4 is not yet in upstream QEMU,
I'm submitting it first to qemu-kvm to avoid conflicts.
 

Looks good to me.
   


Me too.

--
error compiling committee.c: too many arguments to function





[Qemu-devel] Re: [PATCH v2] qemu-kvm: Speed up of the dirty-bitmap-traveling

2010-02-14 Thread Avi Kivity
On 02/12/2010 04:03 AM, OHMURA Kei wrote:
 On 02/11/2010 Anthony Liguori anth...@codemonkey.ws wrote:
   
 Oh, I see what's happening here. Yes, I think a leul_to_cpu() makes more
 sense.
 
 Maybe I'm missing something here.
 I couldn't find leul_to_cpu(), so have defined it in bswap.h.
 Correct?

 --- a/bswap.h
 +++ b/bswap.h
 @@ -205,8 +205,10 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
  
  #ifdef HOST_WORDS_BIGENDIAN
  #define cpu_to_32wu cpu_to_be32wu
 +#define leul_to_cpu(v) le ## HOST_LONG_BITS ## _to_cpu(v)
  #else
  #define cpu_to_32wu cpu_to_le32wu
 +#define leul_to_cpu(v) (v)
  #endif



 On 02/10/2010 Ulrich Drepper drep...@redhat.com wrote:
   
 If you're optimizing this code you might want to do it all.  The
 compiler might not see through the bswap call and create unnecessary
 data dependencies.  Especially problematic if the bitmap is really
 sparse.  Also, the outer test is != while the inner test is .  Be
 consistent.  I suggest to replace the inner loop with

  do {
...
  } while (c != 0);

 Depending on how sparse the bitmap is populated this might reduce the
 number of data dependencies quite a bit.
 
 Combining all comments, the code would be like this.
  
  if (bitmap_ul[i] != 0) {
  c = leul_to_cpu(bitmap_ul[i]);
  do {
  j = ffsl(c) - 1;
  c = ~(1ul  j);
  page_number = i * HOST_LONG_BITS + j;
  addr1 = page_number * TARGET_PAGE_SIZE;
  addr = offset + addr1;
  ram_addr = cpu_get_physical_page_desc(addr);
  cpu_physical_memory_set_dirty(ram_addr);
  } while (c != 0);
  }
   

Except you don't need bitmap_ul any more - you can change the type of
the bitmap variable, since all accesses should now be ulongs.

-- 
error compiling committee.c: too many arguments to function





[Qemu-devel] Re: [PATCH 2/2] net/macvtap: add vhost support

2010-02-14 Thread Michael S. Tsirkin
On Sat, Feb 13, 2010 at 11:35:08AM +0100, Arnd Bergmann wrote:
 This adds support for passing a macvtap file descriptor into
 vhost-net, much like we already do for tun/tap.
 
 Most of the new code is taken from the respective patch
 in the tun driver and may get consolidated in the future.
 
 Signed-off-by: Arnd Bergmann a...@arndb.de
 ---
  drivers/net/macvtap.c  |   98 ++-
  drivers/vhost/net.c|8 +++-
  include/linux/if_macvlan.h |   13 ++
  3 files changed, 96 insertions(+), 23 deletions(-)
 
 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
 index 7050997..e354501 100644
 --- a/drivers/net/macvtap.c
 +++ b/drivers/net/macvtap.c
 @@ -58,6 +58,8 @@ static unsigned int macvtap_major;
  static struct class *macvtap_class;
  static struct cdev macvtap_cdev;
  
 +static const struct proto_ops macvtap_socket_ops;
 +
  /*
   * RCU usage:
   * The macvtap_queue and the macvlan_dev are loosely coupled, the
 @@ -176,7 +178,7 @@ static int macvtap_forward(struct net_device *dev, struct 
 sk_buff *skb)
   return -ENOLINK;
  
   skb_queue_tail(q-sk.sk_receive_queue, skb);
 - wake_up(q-sk.sk_sleep);
 + wake_up_interruptible_poll(q-sk.sk_sleep, POLLIN | POLLRDNORM | 
 POLLRDBAND);
   return 0;
  }
  
 @@ -242,7 +244,7 @@ static void macvtap_sock_write_space(struct sock *sk)
   return;
  
   if (sk-sk_sleep  waitqueue_active(sk-sk_sleep))
 - wake_up_interruptible_sync(sk-sk_sleep);
 + wake_up_interruptible_poll(sk-sk_sleep, POLLOUT | POLLWRNORM | 
 POLLWRBAND);
  }
  
  static int macvtap_open(struct inode *inode, struct file *file)
 @@ -270,6 +272,8 @@ static int macvtap_open(struct inode *inode, struct file 
 *file)
   init_waitqueue_head(q-sock.wait);
   q-sock.type = SOCK_RAW;
   q-sock.state = SS_CONNECTED;
 + q-sock.file = file;
 + q-sock.ops = macvtap_socket_ops;
   sock_init_data(q-sock, q-sk);
   q-sk.sk_write_space = macvtap_sock_write_space;
  
 @@ -387,32 +391,20 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
  
   rcu_read_lock_bh();
   vlan = rcu_dereference(q-vlan);
 - macvlan_count_rx(vlan, len, ret == 0, 0);
 + if (vlan)
 + macvlan_count_rx(vlan, len, ret == 0, 0);
   rcu_read_unlock_bh();
  
   return ret ? ret : len;
  }
  
 -static ssize_t macvtap_aio_read(struct kiocb *iocb, const struct iovec *iv,
 - unsigned long count, loff_t pos)
 +static ssize_t macvtap_do_read(struct macvtap_queue *q, struct kiocb *iocb,
 +const struct iovec *iv, unsigned long len,
 +int noblock)
  {
 - struct file *file = iocb-ki_filp;
 - struct macvtap_queue *q = file-private_data;
 -
   DECLARE_WAITQUEUE(wait, current);
   struct sk_buff *skb;
 - ssize_t len, ret = 0;
 -
 - if (!q) {
 - ret = -ENOLINK;
 - goto out;
 - }
 -
 - len = iov_length(iv, count);
 - if (len  0) {
 - ret = -EINVAL;
 - goto out;
 - }
 + ssize_t ret = 0;
  
   add_wait_queue(q-sk.sk_sleep, wait);
   while (len) {
 @@ -421,7 +413,7 @@ static ssize_t macvtap_aio_read(struct kiocb *iocb, const 
 struct iovec *iv,
   /* Read frames from the queue */
   skb = skb_dequeue(q-sk.sk_receive_queue);
   if (!skb) {
 - if (file-f_flags  O_NONBLOCK) {
 + if (noblock) {
   ret = -EAGAIN;
   break;
   }
 @@ -440,7 +432,24 @@ static ssize_t macvtap_aio_read(struct kiocb *iocb, 
 const struct iovec *iv,
  
   current-state = TASK_RUNNING;
   remove_wait_queue(q-sk.sk_sleep, wait);
 + return ret;
 +}
 +
 +static ssize_t macvtap_aio_read(struct kiocb *iocb, const struct iovec *iv,
 + unsigned long count, loff_t pos)
 +{
 + struct file *file = iocb-ki_filp;
 + struct macvtap_queue *q = file-private_data;
 + ssize_t len, ret = 0;
  
 + len = iov_length(iv, count);
 + if (len  0) {
 + ret = -EINVAL;
 + goto out;
 + }
 +
 + ret = macvtap_do_read(q, iocb, iv, len, file-f_flags  O_NONBLOCK);
 + ret = min_t(ssize_t, ret, len); /* XXX copied from tun.c. Why? */
  out:
   return ret;
  }
 @@ -538,6 +547,53 @@ static const struct file_operations macvtap_fops = {
  #endif
  };
  
 +static int macvtap_sendmsg(struct kiocb *iocb, struct socket *sock,
 +struct msghdr *m, size_t total_len)
 +{
 + struct macvtap_queue *q = container_of(sock, struct macvtap_queue, 
 sock);
 + return macvtap_get_user(q, m-msg_iov, total_len,
 + m-msg_flags  MSG_DONTWAIT);
 +}
 +
 +static int macvtap_recvmsg(struct kiocb *iocb, struct socket *sock,
 +struct msghdr *m, size_t total_len,
 

[Qemu-devel] Re: [PATCH] Give sdl-config higher priority than pkg-config

2010-02-14 Thread Blue Swirl
On Sun, Feb 14, 2010 at 2:04 PM, Paolo Bonzini pbonz...@redhat.com wrote:
 On 02/14/2010 08:23 AM, Blue Swirl wrote:

 On OpenBSD, pkg-config sdl --cflags forgets to add -I/usr/local/include
 which is needed for iconv.h (included from SDL.h). This makes SDL
 detection fail.

 Try sdl-config first, only if it fails try pkg-config.

 This breaks cross-compilation.  I'm CCing the OpenBSD package maintainer so
 that he can fix it.

 Upstream SDL has

    --cflags)
      echo -...@includedir@/SDL @SDL_CFLAGS@
      ;;

 in sdl-config.in and

 Cflags: -I${includedir}/SDL @SDL_CFLAGS@

 in sdl.pc.in, while OpenBSD has different values, so he modified sdl-config
 apparently but not sdl.pc.in.

Right. I think this patch against ports/devel/sdl should do the trick:

--- patches/patch-sdl_pc_in.origSun Feb 14 14:08:41 2010
+++ patches/patch-sdl_pc_in Sun Feb 14 14:10:50 2010
@@ -8,4 +8,4 @@
 -Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@
 -Cflags: -I${includedir}/SDL @SDL_CFLAGS@
 +Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@ @X_LIBS@
-+Cflags: -I${includedir}/SDL @SDL_CFLAGS@ @X_CFLAGS@
++Cflags: -I${includedir} -I${includedir}/SDL @SDL_CFLAGS@ @X_CFLAGS@




[Qemu-devel] [PULL] qemu: pci fixes and cleanups

2010-02-14 Thread Michael S. Tsirkin
The following changes since commit bc798c77e54f73b637e02bdc02bd799660adb7b7:
  Blue Swirl (1):
Remove conditional rom loading support

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu.git for_anthony

Alexander Graf (10):
  PPC: Uninorth config space accessor
  PPC: Use Mac99_U3 type on ppc64
  PPC: Include dump of lspci -nn on real G5
  PPC: Make interrupts work
  PPC: tell the guest about the time base frequency
  PPC: Use macio IDE controller for Newworld
  PPC: Get rid of segfaults in DBDMA emulation
  PPC: Add USB per default on U3
  PPC: Fix large pages
  PPC: Add timer when running KVM

Michael S. Tsirkin (6):
  pci: move pcibus_t to qemu-common
  bwap: add qemu_bswap helper
  rwhandler: simplified way to register for mem/io
  pci_host: rewrite using rwhandler
  versatile_pci: convert to symbolic names
  versatile_pci: cleanup

 Makefile.target|1 +
 bswap.h|6 ++
 hw/mac_dbdma.c |   10 ++-
 hw/pci.h   |1 -
 hw/pci_host.c  |  172 +++
 hw/pci_host.h  |4 +
 hw/pci_host_template.h |  109 --
 hw/pci_ids.h   |1 +
 hw/ppc.h   |2 +
 hw/ppc_mac.h   |1 +
 hw/ppc_newworld.c  |   73 ++--
 hw/ppc_oldworld.c  |9 +++
 hw/unin_pci.c  |  151 +-
 hw/versatile_pci.c |   10 +--
 qemu-common.h  |2 +
 rwhandler.c|   91 +
 rwhandler.h|   27 
 target-ppc/helper.c|9 +--
 target-ppc/kvm.c   |   69 +++
 target-ppc/kvm_ppc.h   |2 +
 20 files changed, 511 insertions(+), 239 deletions(-)
 delete mode 100644 hw/pci_host_template.h
 create mode 100644 rwhandler.c
 create mode 100644 rwhandler.h




Re: [Qemu-devel] qemu-system-ppc -m g3beige -hda is setting /dev/hdc on Linux.

2010-02-14 Thread Alexander Graf

Am Sat 13 Feb 2010 07:29:33 PM CET schrieb Rob Landley r...@landley.net:


On Saturday 13 February 2010 06:04:03 Alexander Graf wrote:

 Exactly, that's the issue to fix here, make DBDMA work with CD-ROM so we
 can get rid of the cmd64x controller.

Speaking of which - in my PPC64 enabling series I use MacIO for all 4 IDE
devices. At least with recent kernels, Linux just detects DMA being broken
on the CD-ROM and doesn't use it.


Could you point me at a copy of that patch?  That sounds like it would be a
decent solution for me, I'm happy to test it if it helps push it upstream.


git://repo.or.cz/qemu/agraf.git

But I don't think testing would help pushing it upstream.


Alex




Re: [Qemu-devel] qemu-ppc can't run static uClibc binaries.

2010-02-14 Thread Alexander Graf

Am Sun 14 Feb 2010 09:36:27 AM CET schrieb Rob Landley r...@landley.net:


On Thursday 11 February 2010 06:32:12 Alexander Graf wrote:

Rob Landley wrote:
 Static binaries that run under the Linux kernel don't run under qemu-ppc.
  For example, the prebuilt busybox binaries here:

   http://busybox.net/downloads/binaries/1.16.0/busybox-powerpc

 Don't run under qemu-ppc, but runs just fine under qemu-system-ppc with
 the image at:


 http://impactlinux.com/fwl/downloads/binaries/system-image-powerpc.tar.bz
2

 The reason is that the powerpc spec that qemu was written to is for
 AIX, not for Linux, and thus the register layout qemu application
 emulation provides for powerpc doesn't match what the kernel is actually
 doing.

 For dynamically linked executables, the dynamic linker reorganizes the
 register contents to match the AIX spec from IBM, but statically linked
 binaries get what the kernel provides directly.  Thus binaries statically
 linked against uClibc won't run under qemu-ppc, but run under
 qemu-system-ppc just fine.

 I tracked down this problem in 2007:

   http://landley.net/notes-2007.html#28-03-2007

 And reported it on the list at the time:

   http://lists.gnu.org/archive/html/qemu-devel/2007-03/msg00713.html
   http://lists.gnu.org/archive/html/qemu-devel/2007-03/msg00720.html
   http://lists.gnu.org/archive/html/qemu-devel/2007-04/msg00315.html

 However, the then-maintainer of powerpc believed nobody else ever had the
 right to touch her code:

   http://lists.gnu.org/archive/html/qemu-devel/2007-04/msg00198.html

 And I was unable to convince her that insisting reality change to match a
 spec which wasn't even for the right platform was not a useful approach.
 Thus the binary in the first link still won't run under qemu-ppc three
 years later, despite running fine under a real Linux kernel.

Patches are always welcome. The only thing you might want to make sure
is that dynamically linked binaries also still continue to work :-).


Attached.

This may help explain the issue:

  http://sources.redhat.com/ml/libc-alpha/2003-03/msg00272.html

It's not a question of dynamically linked Linux binaries.  They work  
 just fine

with either register layout.  The dynamic linker converts the Linux layout to
the AIX layout, and is reentrant so it won't do it a second time if it's
already been converted.

The problem is that BSD wants the AIX layout, and hence this comment  
 in linux-

user/elfload.c function init_thread():

/* Note that isn't exactly what regular kernel does
 * but this is what the ABI wants and is needed to allow
 * execution of PPC BSD programs.
 */

I.E. whoever wrote this already knows it's not what the Linux kernel is
actually doing, and they're not doing it for Linux, they're doing it for BSD.

The fix is probably to add #ifdef CONFIG_BSD around the appropriate chunk of
code.  Attached is a patch to do that (plus tweaks to make the you have an
unused variable, break the build! logic shut up about it).

(Yes, I tested that a dynamically linked hello world still worked for me.)


I don't see why it would fail. The link above states that for  
statically linked binaries, r1 points to all the variables. For  
dynamically linked ones, you also get pointers in some regs.


So the only case I can imagine that this breaks anything is that  
uClibc requires register state to be 0.



Alex




[Qemu-devel] Re: [PATCH] Give sdl-config higher priority than pkg-config

2010-02-14 Thread Paolo Bonzini



Right. I think this patch against ports/devel/sdl should do the trick:

--- patches/patch-sdl_pc_in.origSun Feb 14 14:08:41 2010
+++ patches/patch-sdl_pc_in Sun Feb 14 14:10:50 2010
@@ -8,4 +8,4 @@
  -Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@
  -Cflags: -I${includedir}/SDL @SDL_CFLAGS@
  +Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@ @X_LIBS@
-+Cflags: -I${includedir}/SDL @SDL_CFLAGS@ @X_CFLAGS@
++Cflags: -I${includedir} -I${includedir}/SDL @SDL_CFLAGS@ @X_CFLAGS@


Yep, thanks very much.

Paolo




[Qemu-devel] eepro100: New patch series adds full GPXE support

2010-02-14 Thread Stefan Weil
These patches contain fixes, enhancements and improvements
for eepro100.

Even if some of these patches contain trivial changes which
seem to be optional, they help to synchronize my maintainer
version with the official QEMU version, so please apply them.

0001-eepro100-Fix-compiler-errors-from-debug-messages.patch
0002-eepro100-Add-missing-SCB-register-names.patch
0003-eepro100-Fix-PXE-boot.patch
0004-eepro100-Support-gpxe-boot-for-all-eepro100-devices.patch
0005-eepro100-Add-all-supported-devices-to-pci.c.patch (optional)
0006-eepro100-Add-TODO-list.patch
0007-eepro100-Update-copyright-notice.patch
0008-eepro100-Add-device-descriptions.patch
0009-eepro100-Use-symbolic-names-and-BIT-macros-in-binary.patch
0010-eepro100-Remove-old-unused-code.patch
0011-eepro100-Use-symbolic-names-for-bits-in-EEPROM-id.patch
0012-eepro100-Replace-variable-name-to-fix-a-compiler-war.patch
0013-eepro100-Support-RNR-interrupt.patch
0014-eepro100-Fix-CU-Start-command.patch
0015-eepro100-Prettify-code-no-functional-changes.patch
0016-eepro100-Use-tx.status.patch
0017-eepro100-New-function-for-reading-command-block.patch
0018-eepro100-Add-diagnose-command.patch
0019-eepro100-Remove-C-comments.patch
0020-eepro100-Keep-includes-sorted.patch

There still remain issues (incomplete endianess handling,
buggy transmit command) which will be addressed later.

Regards,
Stefan Weil




[Qemu-devel] [PATCH 01/20] eepro100: Fix compiler errors from debug messages

2010-02-14 Thread Stefan Weil
When debug output was enabled (by defining DEBUG_EEPRO100),
some debug messages resulted in a compiler error.

This is fixed here.

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |   13 +++--
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index b33dbb8..6580ca8 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -56,7 +56,9 @@
 #define KiB 1024
 
 /* Debug EEPRO100 card. */
-//~ #define DEBUG_EEPRO100
+#if 0
+# define DEBUG_EEPRO100
+#endif
 
 #ifdef DEBUG_EEPRO100
 #define logout(fmt, ...) fprintf(stderr, EE100\t%-24s fmt, __func__, ## 
__VA_ARGS__)
@@ -874,9 +876,8 @@ static void action_command(EEPRO100State *s)
 cpu_physical_memory_read(s-cb_address, (uint8_t *)s-tx, 
sizeof(s-tx));
 uint16_t status = le16_to_cpu(s-tx.status);
 uint16_t command = le16_to_cpu(s-tx.command);
-logout
-(val=0x%02x (cu start), status=0x%04x, command=0x%04x, 
link=0x%08x\n,
- val, status, command, s-tx.link);
+logout(val=(cu start), status=0x%04x, command=0x%04x, link=0x%08x\n,
+   status, command, s-tx.link);
 bool bit_el = ((command  0x8000) != 0);
 bool bit_s = ((command  0x4000) != 0);
 bool bit_i = ((command  0x2000) != 0);
@@ -891,7 +892,7 @@ static void action_command(EEPRO100State *s)
 break;
 case CmdIASetup:
 cpu_physical_memory_read(s-cb_address + 8, s-conf.macaddr.a[0], 
6);
-TRACE(OTHER, logout(macaddr: %s\n, nic_dump(s-macaddr[0], 6)));
+TRACE(OTHER, logout(macaddr: %s\n, 
nic_dump(s-conf.macaddr.a[0], 6)));
 break;
 case CmdConfigure:
 cpu_physical_memory_read(s-cb_address + 8, s-configuration[0],
@@ -1875,7 +1876,7 @@ static int nic_init(PCIDevice *pci_dev, uint32_t device)
pci_mmio_map);
 
 qemu_macaddr_default_if_unset(s-conf.macaddr);
-logout(macaddr: %s\n, nic_dump(s-macaddr[0], 6));
+logout(macaddr: %s\n, nic_dump(s-conf.macaddr.a[0], 6));
 assert(s-region[1] == 0);
 
 nic_reset(s);
-- 
1.6.6.1





[Qemu-devel] [PATCH 02/20] eepro100: Add missing SCB register names

2010-02-14 Thread Stefan Weil
Some system control block registers were addressed
using their offset value. Use symbolic names now
and clean the documentation.

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 6580ca8..124bc49 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -125,16 +125,20 @@
 /* Offsets to the various registers.
All accesses need not be longword aligned. */
 enum speedo_offsets {
-SCBStatus = 0,
+SCBStatus = 0,  /* Status Word. */
 SCBAck = 1,
 SCBCmd = 2, /* Rx/Command Unit command and status. */
 SCBIntmask = 3,
 SCBPointer = 4, /* General purpose pointer. */
 SCBPort = 8,/* Misc. commands and operands.  */
-SCBflash = 12, SCBeeprom = 14,  /* EEPROM and flash memory control. */
+SCBflash = 12,  /* Flash memory control. */
+SCBeeprom = 14, /* EEPROM control. */
 SCBCtrlMDI = 16,/* MDI interface control. */
 SCBEarlyRx = 20,/* Early receive byte count. */
-SCBFlow = 24,
+SCBFlow = 24,   /* Flow Control. */
+SCBpmdr = 27,   /* Power Management Driver. */
+SCBgctrl = 28,  /* General Control. */
+SCBgstat = 29,  /* General Status. */
 };
 
 /* A speedo3 transmit buffer descriptor with two buffers... */
@@ -1333,11 +1337,11 @@ static uint8_t eepro100_read1(EEPRO100State * s, 
uint32_t addr)
 case SCBeeprom:
 val = eepro100_read_eeprom(s);
 break;
-case 0x1b: /* PMDR (power management driver register) */
+case SCBpmdr:   /* Power Management Driver Register */
 val = 0;
 TRACE(OTHER, logout(addr=%s val=0x%02x\n, regname(addr), val));
 break;
-case 0x1d: /* general status register */
+case SCBgstat:  /* General Status Register */
 /* 100 Mbps full duplex, valid link */
 val = 0x07;
 TRACE(OTHER, logout(addr=General Status val=%02x\n, val));
@@ -1431,7 +1435,7 @@ static void eepro100_write1(EEPRO100State * s, uint32_t 
addr, uint8_t val)
 case SCBFlow:   /* does not exist on 82557 */
 case SCBFlow + 1:
 case SCBFlow + 2:
-case SCBFlow + 3:
+case SCBpmdr:   /* does not exist on 82557 */
 TRACE(OTHER, logout(addr=%s val=0x%02x\n, regname(addr), val));
 break;
 case SCBeeprom:
-- 
1.6.6.1





[Qemu-devel] [PATCH 03/20] eepro100: Fix PXE boot

2010-02-14 Thread Stefan Weil
The phy handling was wrong for PXE, GPXE boot:
GPXE's eepro100 driver did not detect a valid link.

This is fixed here.

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |   20 ++--
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 124bc49..994722d 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -20,7 +20,7 @@
  * along with this program; if not, see http://www.gnu.org/licenses/.
  *
  * Tested features (i82559):
- *  PXE boot (i386) no valid link
+ *  PXE boot (i386) ok
  *  Linux networking (i386) ok
  *
  * Untested:
@@ -33,10 +33,6 @@
  * Open Source Software Developer Manual
  */
 
-#if defined(TARGET_I386)
-# warning PXE boot still not working!
-#endif
-
 #include stddef.h /* offsetof */
 #include stdbool.h
 #include hw.h
@@ -243,6 +239,17 @@ typedef struct {
 bool has_extended_tcb_support;
 } EEPRO100State;
 
+/* Word indices in EEPROM. */
+typedef enum {
+eeprom_cnfg_mdix  = 0x03,
+eeprom_id = 0x05,
+eeprom_phy_id = 0x06,
+eeprom_vendor_id  = 0x0c,
+eeprom_config_asf = 0x0d,
+eeprom_device_id  = 0x23,
+eeprom_smbus_addr = 0x90,
+} EEPROMOffset;
+
 /* Default values for MDI (PHY) registers */
 static const uint16_t eepro100_mdi_default[] = {
 /* MDI Registers 0 - 6, 7 */
@@ -632,9 +639,10 @@ static void nic_selective_reset(EEPRO100State * s)
 uint16_t *eeprom_contents = eeprom93xx_data(s-eeprom);
 //~ eeprom93xx_reset(s-eeprom);
 memcpy(eeprom_contents, s-conf.macaddr.a, 6);
-eeprom_contents[0xa] = 0x4000;
+eeprom_contents[eeprom_id] = 0x4000;
 if (s-device == i82557B || s-device == i82557C)
 eeprom_contents[5] = 0x0100;
+eeprom_contents[eeprom_phy_id] = 1;
 uint16_t sum = 0;
 for (i = 0; i  EEPROM_SIZE - 1; i++) {
 sum += eeprom_contents[i];
-- 
1.6.6.1





[Qemu-devel] [PATCH 05/20] eepro100: Add all supported devices to pci.c

2010-02-14 Thread Stefan Weil
All eepro100 devices work with drivers which
only use basic features.

They were tested with gpxe boot.

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/pci.c |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index eb2043e..1ba3f92 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1436,9 +1436,18 @@ void do_pci_info(Monitor *mon, QObject **ret_data)
 
 static const char * const pci_nic_models[] = {
 ne2k_pci,
+i82550,
 i82551,
+i82557a,
 i82557b,
+i82557c,
+i82558a,
+i82558b,
+i82559a,
+i82559b,
+i82559c,
 i82559er,
+i82562,
 rtl8139,
 e1000,
 pcnet,
@@ -1448,9 +1457,18 @@ static const char * const pci_nic_models[] = {
 
 static const char * const pci_nic_names[] = {
 ne2k_pci,
+i82550,
 i82551,
+i82557a,
 i82557b,
+i82557c,
+i82558a,
+i82558b,
+i82559a,
+i82559b,
+i82559c,
 i82559er,
+i82562,
 rtl8139,
 e1000,
 pcnet,
-- 
1.6.6.1





[Qemu-devel] [PATCH 06/20] eepro100: Add TODO list

2010-02-14 Thread Stefan Weil
Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 179c544..b93667a 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -31,6 +31,14 @@
  *
  * Intel 8255x 10/100 Mbps Ethernet Controller Family
  * Open Source Software Developer Manual
+ *
+ * TODO:
+ *  * PHY emulation should be separated from nic emulation.
+ *Most nic emulations could share the same phy code.
+ *  * i82550 is untested. It is programmed like the i82559.
+ *  * i82562 is untested. It is programmed like the i82559.
+ *  * Power management (i82558 and later) is not implemented.
+ *  * Wake-on-LAN is not implemented.
  */
 
 #include stddef.h /* offsetof */
-- 
1.6.6.1





[Qemu-devel] [PATCH 07/20] eepro100: Update copyright notice

2010-02-14 Thread Stefan Weil
Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index b93667a..3e2f008 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -1,15 +1,15 @@
 /*
  * QEMU i8255x (PRO100) emulation
  *
- * Copyright (c) 2006-2007 Stefan Weil
+ * Copyright (C) 2006-2010 Stefan Weil
  *
  * Portions of the code are copies from grub / etherboot eepro100.c
  * and linux e100.c.
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) version 3 or any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,7 +17,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, see http://www.gnu.org/licenses/.
+ * along with this program.  If not, see http://www.gnu.org/licenses/.
  *
  * Tested features (i82559):
  *  PXE boot (i386) ok
-- 
1.6.6.1





[Qemu-devel] [PATCH 08/20] eepro100: Add device descriptions

2010-02-14 Thread Stefan Weil
Add descriptions for all devices.
These descriptions are shown when users call
qemu -device ?

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 3e2f008..031fe69 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -1980,6 +1980,7 @@ static int pci_i82562_init(PCIDevice *pci_dev)
 static PCIDeviceInfo eepro100_info[] = {
 {
 .qdev.name = i82550,
+.qdev.desc = Intel i82550 Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82550_init,
 .exit  = pci_nic_uninit,
@@ -1990,6 +1991,7 @@ static PCIDeviceInfo eepro100_info[] = {
 },
 },{
 .qdev.name = i82551,
+.qdev.desc = Intel i82551 Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82551_init,
 .exit  = pci_nic_uninit,
@@ -2000,6 +2002,7 @@ static PCIDeviceInfo eepro100_info[] = {
 },
 },{
 .qdev.name = i82557a,
+.qdev.desc = Intel i82557A Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82557a_init,
 .exit  = pci_nic_uninit,
@@ -2010,6 +2013,7 @@ static PCIDeviceInfo eepro100_info[] = {
 },
 },{
 .qdev.name = i82557b,
+.qdev.desc = Intel i82557B Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82557b_init,
 .exit  = pci_nic_uninit,
@@ -2020,6 +2024,7 @@ static PCIDeviceInfo eepro100_info[] = {
 },
 },{
 .qdev.name = i82557c,
+.qdev.desc = Intel i82557C Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82557c_init,
 .exit  = pci_nic_uninit,
@@ -2030,6 +2035,7 @@ static PCIDeviceInfo eepro100_info[] = {
 },
 },{
 .qdev.name = i82558a,
+.qdev.desc = Intel i82558A Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82558a_init,
 .exit  = pci_nic_uninit,
@@ -2040,6 +2046,7 @@ static PCIDeviceInfo eepro100_info[] = {
 },
 },{
 .qdev.name = i82558b,
+.qdev.desc = Intel i82558B Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82558b_init,
 .exit  = pci_nic_uninit,
@@ -2050,6 +2057,7 @@ static PCIDeviceInfo eepro100_info[] = {
 },
 },{
 .qdev.name = i82559a,
+.qdev.desc = Intel i82559A Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82559a_init,
 .exit  = pci_nic_uninit,
@@ -2060,6 +2068,7 @@ static PCIDeviceInfo eepro100_info[] = {
 },
 },{
 .qdev.name = i82559b,
+.qdev.desc = Intel i82559B Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82559b_init,
 .exit  = pci_nic_uninit,
@@ -2070,6 +2079,7 @@ static PCIDeviceInfo eepro100_info[] = {
 },
 },{
 .qdev.name = i82559c,
+.qdev.desc = Intel i82559C Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82559c_init,
 .exit  = pci_nic_uninit,
@@ -2080,6 +2090,7 @@ static PCIDeviceInfo eepro100_info[] = {
 },
 },{
 .qdev.name = i82559er,
+.qdev.desc = Intel i82559ER Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82559er_init,
 .exit  = pci_nic_uninit,
@@ -2090,6 +2101,7 @@ static PCIDeviceInfo eepro100_info[] = {
 },
 },{
 .qdev.name = i82562,
+.qdev.desc = Intel i82562 Ethernet,
 .qdev.size = sizeof(EEPRO100State),
 .init  = pci_i82562_init,
 .exit  = pci_nic_uninit,
-- 
1.6.6.1





[Qemu-devel] [PATCH 11/20] eepro100: Use symbolic names for bits in EEPROM id

2010-02-14 Thread Stefan Weil
Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |   17 -
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index c647322..01bcd6d 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -272,6 +272,21 @@ typedef enum {
 eeprom_smbus_addr = 0x90,
 } EEPROMOffset;
 
+/* Bit values for EEPROM ID word. */
+typedef enum {
+eeprom_id_mdm = BIT(0), /* Modem */
+eeprom_id_stb = BIT(1), /* Standby Enable */
+eeprom_id_wmr = BIT(2), /* ??? */
+eeprom_id_wol = BIT(5), /* Wake on LAN */
+eeprom_id_dpd = BIT(6), /* Deep Power Down */
+eeprom_id_alt = BIT(7), /* */
+/* BITS(10, 8) device revision */
+eeprom_id_bd = BIT(11), /* boot disable */
+eeprom_id_id = BIT(13), /* id bit */
+/* BITS(15, 14) signature */
+eeprom_id_valid = BIT(14),  /* signature for valid eeprom */
+} eeprom_id_bit;
+
 /* Default values for MDI (PHY) registers */
 static const uint16_t eepro100_mdi_default[] = {
 /* MDI Registers 0 - 6, 7 */
@@ -643,7 +658,7 @@ static void nic_selective_reset(EEPRO100State * s)
 uint16_t *eeprom_contents = eeprom93xx_data(s-eeprom);
 //~ eeprom93xx_reset(s-eeprom);
 memcpy(eeprom_contents, s-conf.macaddr.a, 6);
-eeprom_contents[eeprom_id] = 0x4000;
+eeprom_contents[eeprom_id] = eeprom_id_valid;
 if (s-device == i82557B || s-device == i82557C)
 eeprom_contents[5] = 0x0100;
 eeprom_contents[eeprom_phy_id] = 1;
-- 
1.6.6.1





[Qemu-devel] [PATCH 10/20] eepro100: Remove old unused code

2010-02-14 Thread Stefan Weil
This code is no longer needed.

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |   18 --
 1 files changed, 0 insertions(+), 18 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 1ce2cd1..c647322 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -469,24 +469,6 @@ static void pci_reset(EEPRO100State * s)
 PCI_CONFIG_8(PCI_LATENCY_TIMER, 0x20);   // latency timer = 32 clocks
 /* PCI Header Type */
 /* BIST (built-in self test) */
-#if defined(TARGET_I386)
-// !!! workaround for buggy bios
-//~ #define PCI_BASE_ADDRESS_MEM_PREFETCH 0
-#endif
-#if 0
-/* PCI Base Address Registers */
-/* CSR Memory Mapped Base Address */
-PCI_CONFIG_32(PCI_BASE_ADDRESS_0,
-  PCI_BASE_ADDRESS_SPACE_MEMORY |
-  PCI_BASE_ADDRESS_MEM_PREFETCH);
-/* CSR I/O Mapped Base Address */
-PCI_CONFIG_32(PCI_BASE_ADDRESS_1, PCI_BASE_ADDRESS_SPACE_IO);
-#if 0
-/* Flash Memory Mapped Base Address */
-PCI_CONFIG_32(PCI_BASE_ADDRESS_2,
-  0xfffe | PCI_BASE_ADDRESS_SPACE_MEMORY);
-#endif
-#endif
 /* Expansion ROM Base Address (depends on boot disable!!!) */
 /* TODO: not needed, set when BAR is registered */
 PCI_CONFIG_32(PCI_ROM_ADDRESS, PCI_BASE_ADDRESS_SPACE_MEMORY);
-- 
1.6.6.1





[Qemu-devel] [PATCH 12/20] eepro100: Replace variable name to fix a compiler warning

2010-02-14 Thread Stefan Weil
When compiling with -Wshadow, gcc gives a warning
which is fixed by renaming stat - status.

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 01bcd6d..b5bd05b 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -392,14 +392,14 @@ static void eepro100_acknowledge(EEPRO100State * s)
 }
 }
 
-static void eepro100_interrupt(EEPRO100State * s, uint8_t stat)
+static void eepro100_interrupt(EEPRO100State * s, uint8_t status)
 {
 uint8_t mask = ~s-mem[SCBIntmask];
-s-mem[SCBAck] |= stat;
-stat = s-scb_stat = s-mem[SCBAck];
-stat = (mask | 0x0f);
-//~ stat = (~s-mem[SCBIntmask] | 0x0xf);
-if (stat  (mask  0x01)) {
+s-mem[SCBAck] |= status;
+status = s-scb_stat = s-mem[SCBAck];
+status = (mask | 0x0f);
+//~ status = (~s-mem[SCBIntmask] | 0x0xf);
+if (status  (mask  0x01)) {
 /* SCB mask and SCB Bit M do not disable interrupt. */
 enable_interrupt(s);
 } else if (s-int_stat) {
-- 
1.6.6.1





[Qemu-devel] [PATCH 13/20] eepro100: Support RNR interrupt

2010-02-14 Thread Stefan Weil
The RNR interrupt is triggered under these conditions:

* the RU is not ready to receive a frame due to missing resources
* the RU is ready and a RU abort command was requested

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |   13 ++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index b5bd05b..37176cd 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -120,7 +120,7 @@
 #define  RU_NOP 0x
 #define  RX_START   0x0001
 #define  RX_RESUME  0x0002
-#define  RX_ABORT   0x0004
+#define  RU_ABORT   0x0004
 #define  RX_ADDR_LOAD   0x0006
 #define  RX_RESUMENR0x0007
 #define INT_MASK0x0100
@@ -426,13 +426,11 @@ static void eepro100_fr_interrupt(EEPRO100State * s)
 eepro100_interrupt(s, 0x40);
 }
 
-#if 0
 static void eepro100_rnr_interrupt(EEPRO100State * s)
 {
 /* RU is not ready. */
 eepro100_interrupt(s, 0x10);
 }
-#endif
 
 static void eepro100_mdi_interrupt(EEPRO100State * s)
 {
@@ -1065,6 +1063,13 @@ static void eepro100_ru_command(EEPRO100State * s, 
uint8_t val)
 }
 set_ru_state(s, ru_ready);
 break;
+case RU_ABORT:
+/* RU abort. */
+if (get_ru_state(s) == ru_ready) {
+eepro100_rnr_interrupt(s);
+}
+set_ru_state(s, ru_idle);
+break;
 case RX_ADDR_LOAD:
 /* Load RU base. */
 TRACE(OTHER, logout(val=0x%02x (RU base address)\n, val));
@@ -1747,6 +1752,8 @@ static ssize_t nic_receive(VLANClientState *nc, const 
uint8_t * buf, size_t size
 if (get_ru_state(s) != ru_ready) {
 /* No resources available. */
 logout(no resources, state=%u\n, get_ru_state(s));
+/* TODO: RNR interrupt only at first failed frame? */
+eepro100_rnr_interrupt(s);
 s-statistics.rx_resource_errors++;
 //~ assert(!no resources);
 return -1;
-- 
1.6.6.1





[Qemu-devel] [PATCH 16/20] eepro100: Use tx.status

2010-02-14 Thread Stefan Weil
There is no need for a local variable status.
Using tx.status makes it clearer which status
is addressed.

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 368a9d6..ebf0f7d 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -903,10 +903,10 @@ static void action_command(EEPRO100State *s)
 for (;;) {
 s-cb_address = s-cu_base + s-cu_offset;
 cpu_physical_memory_read(s-cb_address, (uint8_t *)s-tx, 
sizeof(s-tx));
-uint16_t status = le16_to_cpu(s-tx.status);
 uint16_t command = le16_to_cpu(s-tx.command);
+s-tx.status = le16_to_cpu(s-tx.status);
 logout(val=(cu start), status=0x%04x, command=0x%04x, link=0x%08x\n,
-   status, command, s-tx.link);
+   s-tx.status, command, s-tx.link);
 bool bit_el = ((command  COMMAND_EL) != 0);
 bool bit_s = ((command  COMMAND_S) != 0);
 bool bit_i = ((command  COMMAND_I) != 0);
@@ -950,7 +950,7 @@ static void action_command(EEPRO100State *s)
 break;
 }
 /* Write new status. */
-stw_phys(s-cb_address, status | STATUS_C | (success ? STATUS_OK : 0));
+stw_phys(s-cb_address, s-tx.status | STATUS_C | (success ? STATUS_OK 
: 0));
 if (bit_i) {
 /* CU completed action. */
 eepro100_cx_interrupt(s);
-- 
1.6.6.1





[Qemu-devel] [PATCH 17/20] eepro100: New function for reading command block

2010-02-14 Thread Stefan Weil
Move code which reads the command block to the
new function read_cb. The patch also fixes some
endianess issues related to the command block
and moves declarations of local variables to
the beginning of the block.

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |   42 --
 1 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index ebf0f7d..43595eb 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -798,6 +798,16 @@ static void dump_statistics(EEPRO100State * s)
 //~ missing(CU dump statistical counters);
 }
 
+static void read_cb(EEPRO100State *s)
+{
+cpu_physical_memory_read(s-cb_address, (uint8_t *) s-tx, sizeof(s-tx));
+s-tx.status = le16_to_cpu(s-tx.status);
+s-tx.command = le16_to_cpu(s-tx.command);
+s-tx.link = le32_to_cpu(s-tx.link);
+s-tx.tbd_array_addr = le32_to_cpu(s-tx.tbd_array_addr);
+s-tx.tcb_bytes = le16_to_cpu(s-tx.tcb_bytes);
+}
+
 static void tx_command(EEPRO100State *s)
 {
 uint32_t tbd_array = le32_to_cpu(s-tx.tbd_array_addr);
@@ -901,21 +911,25 @@ static void set_multicast_list(EEPRO100State *s)
 static void action_command(EEPRO100State *s)
 {
 for (;;) {
-s-cb_address = s-cu_base + s-cu_offset;
-cpu_physical_memory_read(s-cb_address, (uint8_t *)s-tx, 
sizeof(s-tx));
-uint16_t command = le16_to_cpu(s-tx.command);
-s-tx.status = le16_to_cpu(s-tx.status);
-logout(val=(cu start), status=0x%04x, command=0x%04x, link=0x%08x\n,
-   s-tx.status, command, s-tx.link);
-bool bit_el = ((command  COMMAND_EL) != 0);
-bool bit_s = ((command  COMMAND_S) != 0);
-bool bit_i = ((command  COMMAND_I) != 0);
-bool bit_nc = ((command  COMMAND_NC) != 0);
+bool bit_el;
+bool bit_s;
+bool bit_i;
+bool bit_nc;
 bool success = true;
-//~ bool bit_sf = ((command  COMMAND_SF) != 0);
-uint16_t cmd = command  COMMAND_CMD;
-s-cu_offset = le32_to_cpu(s-tx.link);
-switch (cmd) {
+s-cb_address = s-cu_base + s-cu_offset;
+read_cb(s);
+bit_el = ((s-tx.command  COMMAND_EL) != 0);
+bit_s = ((s-tx.command  COMMAND_S) != 0);
+bit_i = ((s-tx.command  COMMAND_I) != 0);
+bit_nc = ((s-tx.command  COMMAND_NC) != 0);
+#if 0
+bool bit_sf = ((s-tx.command  COMMAND_SF) != 0);
+#endif
+s-cu_offset = s-tx.link;
+TRACE(OTHER,
+  logout(val=(cu start), status=0x%04x, command=0x%04x, 
link=0x%08x\n,
+ s-tx.status, s-tx.command, s-tx.link));
+switch (s-tx.command  COMMAND_CMD) {
 case CmdNOp:
 /* Do nothing. */
 break;
-- 
1.6.6.1





[Qemu-devel] [PATCH 18/20] eepro100: Add diagnose command

2010-02-14 Thread Stefan Weil
Real hardware would run an internal self-test.
The emulation just returns a passed status.

Original patch was from Reimar Döffinger, thanks.

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 43595eb..1ac89ef 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -958,6 +958,11 @@ static void action_command(EEPRO100State *s)
 /* Starting with offset 8, the command contains
  * 64 dwords microcode which we just ignore here. */
 break;
+case CmdDiagnose:
+TRACE(OTHER, logout(diagnose\n));
+/* Make sure error flag is not set. */
+s-tx.status = 0;
+break;
 default:
 missing(undefined command);
 success = false;
-- 
1.6.6.1





[Qemu-devel] [PATCH 20/20] eepro100: Keep includes sorted

2010-02-14 Thread Stefan Weil
I always try to keep standard includes sorted
and add a comment why they are there (so they
can be removed when they are no longer needed).

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 0f5fffa..3bd8bd3 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -41,8 +41,8 @@
  *  * Wake-on-LAN is not implemented.
  */
 
+#include stdbool.h/* bool */
 #include stddef.h /* offsetof */
-#include stdbool.h
 #include hw.h
 #include pci.h
 #include net.h
-- 
1.6.6.1





[Qemu-devel] [PATCH 19/20] eepro100: Remove C++ comments

2010-02-14 Thread Stefan Weil
C++ comments are unwanted, so this is fixed here.

* Replace C++ comments by C comments.
* Put code which was deactivated by a C++ comment in #if 0...#endif.

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 hw/eepro100.c |  185 +++--
 1 files changed, 126 insertions(+), 59 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 1ac89ef..0f5fffa 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -154,11 +154,13 @@ typedef struct {
 uint16_t tcb_bytes; /* transmit command block byte count (in lower 
14 bits */
 uint8_t tx_threshold;   /* transmit threshold */
 uint8_t tbd_count;  /* TBD number */
-//~ /* This constitutes two TBD entries: hdr and data */
-//~ uint32_t tx_buf_addr0;  /* void *, header of frame to be transmitted.  
*/
-//~ int32_t  tx_buf_size0;  /* Length of Tx hdr. */
-//~ uint32_t tx_buf_addr1;  /* void *, data to be transmitted.  */
-//~ int32_t  tx_buf_size1;  /* Length of Tx data. */
+#if 0
+/* This constitutes two TBD entries: hdr and data */
+uint32_t tx_buf_addr0;  /* void *, header of frame to be transmitted.  */
+int32_t  tx_buf_size0;  /* Length of Tx hdr. */
+uint32_t tx_buf_addr1;  /* void *, data to be transmitted.  */
+int32_t  tx_buf_size1;  /* Length of Tx data. */
+#endif
 } eepro100_tx_t;
 
 /* Receive frame descriptor. */
@@ -398,7 +400,9 @@ static void eepro100_interrupt(EEPRO100State * s, uint8_t 
status)
 s-mem[SCBAck] |= status;
 status = s-scb_stat = s-mem[SCBAck];
 status = (mask | 0x0f);
-//~ status = (~s-mem[SCBIntmask] | 0x0xf);
+#if 0
+status = (~s-mem[SCBIntmask] | 0x0xf);
+#endif
 if (status  (mask  0x01)) {
 /* SCB mask and SCB Bit M do not disable interrupt. */
 enable_interrupt(s);
@@ -477,9 +481,11 @@ static void pci_reset(EEPRO100State * s)
 pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
 /* PCI Cache Line Size */
 /* check cache line size!!! */
-//~ PCI_CONFIG_8(0x0c, 0x00);
+#if 0
+PCI_CONFIG_8(0x0c, 0x00);
+#endif
 /* PCI Latency Timer */
-PCI_CONFIG_8(PCI_LATENCY_TIMER, 0x20);   // latency timer = 32 clocks
+PCI_CONFIG_8(PCI_LATENCY_TIMER, 0x20);   /* latency timer = 32 clocks */
 /* PCI Header Type */
 /* BIST (built-in self test) */
 /* Expansion ROM Base Address (depends on boot disable!!!) */
@@ -492,7 +498,7 @@ static void pci_reset(EEPRO100State * s)
 /* Interrupt Line */
 /* Interrupt Pin */
 /* TODO: RST# value should be 0 */
-PCI_CONFIG_8(PCI_INTERRUPT_PIN, 1);  // interrupt pin 0
+PCI_CONFIG_8(PCI_INTERRUPT_PIN, 1);  /* interrupt pin 0 */
 /* Minimum Grant */
 PCI_CONFIG_8(PCI_MIN_GNT, 0x08);
 /* Maximum Latency */
@@ -500,20 +506,20 @@ static void pci_reset(EEPRO100State * s)
 
 switch (device) {
 case i82550:
-// TODO: check device id.
+/* TODO: check device id. */
 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82551IT);
 /* Revision ID: 0x0c, 0x0d, 0x0e. */
 PCI_CONFIG_8(PCI_REVISION_ID, 0x0e);
-// TODO: check size of statistical counters.
+/* TODO: check size of statistical counters. */
 s-stats_size = 80;
-// TODO: check extended tcb support.
+/* TODO: check extended tcb support. */
 s-has_extended_tcb_support = 1;
 break;
 case i82551:
 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82551IT);
 /* Revision ID: 0x0f, 0x10. */
 PCI_CONFIG_8(PCI_REVISION_ID, 0x0f);
-// TODO: check size of statistical counters.
+/* TODO: check size of statistical counters. */
 s-stats_size = 80;
 s-has_extended_tcb_support = 1;
 break;
@@ -572,7 +578,7 @@ static void pci_reset(EEPRO100State * s)
 PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
   PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
 PCI_CONFIG_8(PCI_REVISION_ID, 0x08);
-// TODO: Windows wants revision id 0x0c.
+/* TODO: Windows wants revision id 0x0c. */
 PCI_CONFIG_8(PCI_REVISION_ID, 0x0c);
 #if EEPROM_SIZE  0
 PCI_CONFIG_16(PCI_SUBSYSTEM_VENDOR_ID, 0x8086);
@@ -590,7 +596,7 @@ static void pci_reset(EEPRO100State * s)
 s-has_extended_tcb_support = 1;
 break;
 case i82562:
-// TODO: check device id.
+/* TODO: check device id. */
 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82551IT);
 /* TODO: wrong revision id. */
 PCI_CONFIG_8(PCI_REVISION_ID, 0x0e);
@@ -637,14 +643,16 @@ static void pci_reset(EEPRO100State * s)
 
 #if EEPROM_SIZE  0
 if (device == i82557C || device == i82558B || device == i82559C) {
-// TODO: get vendor id from EEPROM for i82557C or later.
-// TODO: get device id from EEPROM for i82557C or later.
-// TODO: status bit 4 can be disabled by EEPROM for 

[Qemu-devel] Re: [PATCH] Give sdl-config higher priority than pkg-config

2010-02-14 Thread Jacob Meuser
On Sun, Feb 14, 2010 at 01:04:31PM +0100, Paolo Bonzini wrote:
 On 02/14/2010 08:23 AM, Blue Swirl wrote:
 On OpenBSD, pkg-config sdl --cflags forgets to add -I/usr/local/include
 which is needed for iconv.h (included from SDL.h). This makes SDL
 detection fail.
 
 Try sdl-config first, only if it fails try pkg-config.
 
 This breaks cross-compilation.  I'm CCing the OpenBSD package
 maintainer so that he can fix it.
 
 Upstream SDL has
 
 --cflags)
   echo -...@includedir@/SDL @SDL_CFLAGS@
   ;;
 
 in sdl-config.in and
 
 Cflags: -I${includedir}/SDL @SDL_CFLAGS@
 
 in sdl.pc.in, while OpenBSD has different values, so he modified
 sdl-config apparently but not sdl.pc.in.

that was done before I became maintainer.  anyway, I'll fix it after
ports unlocks.  thanks for the notice.

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org




[Qemu-devel] [PATCH 0/3] target-arm: Thumb(-2) exception support

2010-02-14 Thread Rabin Vincent
This series adds Thumb exception support and fixes a couple of instructions
related to it.

With these patches, QEMU can boot a Linux kernel built with Thumb-2.

Rabin Vincent (3):
  target-arm: fix thumb CPS
  target-arm: implement Thumb-2 exception return
  target-arm: support thumb exception handlers

 target-arm/helper.c|5 ++---
 target-arm/translate.c |   15 ---
 2 files changed, 14 insertions(+), 6 deletions(-)





[Qemu-devel] [PATCH 2/3] target-arm: implement Thumb-2 exception return

2010-02-14 Thread Rabin Vincent
Support the subs pc, lr Thumb-2 exception return instruction.

Signed-off-by: Rabin Vincent ra...@rab.in
---
 target-arm/translate.c |   13 +++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 10a516b..f0667e5 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -8001,8 +8001,17 @@ static int disas_thumb2_insn(CPUState *env, DisasContext 
*s, uint16_t insn_hw1)
 gen_bx(s, tmp);
 break;
 case 5: /* Exception return.  */
-/* Unpredictable in user mode.  */
-goto illegal_op;
+if (IS_USER(s)) {
+goto illegal_op;
+}
+
+tmp = load_reg(s, rn);
+tmp2 = new_tmp();
+tcg_gen_movi_i32(tmp2, insn  0xff);
+gen_helper_sub_cc(tmp, tmp, tmp2);
+gen_exception_return(s, tmp);
+dead_tmp(tmp2);
+break;
 case 6: /* mrs cpsr.  */
 tmp = new_tmp();
 if (IS_M(env)) {
-- 
1.6.6





[Qemu-devel] [PATCH 1/3] target-arm: fix thumb CPS

2010-02-14 Thread Rabin Vincent
The Thumb CPS currently does not work correctly: CPSID touches more bits
than the instruction wants to, and CPSIE does nothing.  Fix it by
passing the correct mask (the affect bits) and value.

Signed-off-by: Rabin Vincent ra...@rab.in
---
 target-arm/translate.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 786c329..10a516b 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -8898,7 +8898,7 @@ static void disas_thumb_insn(CPUState *env, DisasContext 
*s)
 shift = CPSR_A | CPSR_I | CPSR_F;
 else
 shift = 0;
-gen_set_psr_im(s, shift, 0, ((insn  7)  6)  shift);
+gen_set_psr_im(s, ((insn  7)  6), 0, shift);
 }
 break;
 
-- 
1.6.6





Re: [Qemu-devel] Thumb-2 Support

2010-02-14 Thread Rabin Vincent
On Wed, Sep 23, 2009 at 02:30:01PM +0200, Crooks (Rigante) wrote:
 I was wondering what level of support there is for Thumb-2. (Qemu 0.11 RC2)
 I've compiled two linux-kernels, one with Thumb-2, and one without Thumb-2,
 using the codesourcery compilers. I've then tried to boot these kernels with
 the RealView emulation running an Cortex-A8 CPU.
 The one without Thumb-2 manages to boot, but nothing seem to happen when
 running the one compiled for Thumb-2.

This should work now, if you use the latest QEMU git and apply the three
patches I just sent to the list.  Make sure you boot a uImage, because
when using a zImage QEMU always starts up in ARM mode.

Rabin




[Qemu-devel] [PATCH 3/3] Add FreeBSD/ppc host TCG_TARGET_CALL_{ALIGN_ARGS,STACK_OFFSET} definitions.

2010-02-14 Thread Juergen Lock
Submitted by: Andreas Tobler andre...@fgznet.ch

Signed-off-by: Juergen Lock n...@jelal.kn-bremen.de

--- a/tcg/ppc/tcg-target.h
+++ b/tcg/ppc/tcg-target.h
@@ -69,7 +69,7 @@
 #define TCG_TARGET_CALL_STACK_OFFSET 24
 #elif defined _AIX
 #define TCG_TARGET_CALL_STACK_OFFSET 52
-#elif defined __linux__
+#elif defined __linux__ || defined __FreeBSD__ || defined(__FreeBSD_kernel__)
 #define TCG_TARGET_CALL_ALIGN_ARGS 1
 #define TCG_TARGET_CALL_STACK_OFFSET 8
 #else




[Qemu-devel] [PATCH 1/3] Add FreeBSD/ppc host ppc_init_cacheline_sizes() implementation.

2010-02-14 Thread Juergen Lock
Submitted by: Andreas Tobler andre...@fgznet.ch

Signed-off-by: Juergen Lock n...@jelal.kn-bremen.de

--- a/cache-utils.c
+++ b/cache-utils.c
@@ -57,6 +57,23 @@
 }
 #endif
 
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include stdio.h
+#include sys/types.h
+#include sys/sysctl.h
+
+static void ppc_init_cacheline_sizes(void)
+{
+size_t len = 4;
+unsigned cacheline;
+
+sysctlbyname (machdep.cacheline_size, cacheline, len, NULL, 0);
+
+qemu_cache_conf.dcache_bsize = cacheline;
+qemu_cache_conf.icache_bsize = cacheline;
+}
+#endif
+
 #ifdef __linux__
 void qemu_cache_utils_init(char **envp)
 {




[Qemu-devel] [PATCH 2/3] Add FreeBSD/ppc host ucontext definitions.

2010-02-14 Thread Juergen Lock
Submitted by: Andreas Tobler andre...@fgznet.ch

Signed-off-by: Juergen Lock n...@jelal.kn-bremen.de

--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -933,6 +933,20 @@
 # define TRAP_sig(context) REG_sig(trap, context)
 #endif /* linux */
 
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include ucontext.h
+# define IAR_sig(context)  ((context)-uc_mcontext.mc_srr0)
+# define MSR_sig(context)  ((context)-uc_mcontext.mc_srr1)
+# define CTR_sig(context)  ((context)-uc_mcontext.mc_ctr)
+# define XER_sig(context)  ((context)-uc_mcontext.mc_xer)
+# define LR_sig(context)   ((context)-uc_mcontext.mc_lr)
+# define CR_sig(context)   ((context)-uc_mcontext.mc_cr)
+/* Exception Registers access */
+# define DAR_sig(context)  ((context)-uc_mcontext.mc_dar)
+# define DSISR_sig(context)((context)-uc_mcontext.mc_dsisr)
+# define TRAP_sig(context) ((context)-uc_mcontext.mc_exc)
+#endif /* __FreeBSD__|| __FreeBSD_kernel__ */
+
 #ifdef __APPLE__
 # include sys/ucontext.h
 typedef struct ucontext SIGCONTEXT;
@@ -962,7 +976,11 @@
void *puc)
 {
 siginfo_t *info = pinfo;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ucontext_t *uc = puc;
+#else
 struct ucontext *uc = puc;
+#endif
 unsigned long pc;
 int is_write;
 




[Qemu-devel] [PATCH 0/3] FreeBSD/ppc host patches

2010-02-14 Thread Juergen Lock
Hi!

 These are patches submitted by Andreas Tobler to get qemu working on
FreeBSD/ppc hosts.  There is one other patch to ppc.ld that's needed
because of FreeBSD's older binutils that probably should stay
FreeBSD-specific, here is the link to it in FreeBSD ports:

http://www.freebsd.org/cgi/cvsweb.cgi/ports/emulators/qemu-devel/files/patch-ppc.ld

1. Add FreeBSD/ppc host ppc_init_cacheline_sizes() implementation.

2. Add FreeBSD/ppc host ucontext definitions.

3. Add FreeBSD/ppc host TCG_TARGET_CALL_{ALIGN_ARGS,STACK_OFFSET} definitions.




Re: [Qemu-devel] [PATCH 1/3] Add FreeBSD/ppc host ppc_init_cacheline_sizes() implementation.

2010-02-14 Thread malc
On Sun, 14 Feb 2010, Juergen Lock wrote:

 Submitted by: Andreas Tobler andre...@fgznet.ch
 
 Signed-off-by: Juergen Lock n...@jelal.kn-bremen.de
 
 --- a/cache-utils.c
 +++ b/cache-utils.c
 @@ -57,6 +57,23 @@
  }
  #endif
  
 +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 +#include stdio.h
 +#include sys/types.h
 +#include sys/sysctl.h
 +
 +static void ppc_init_cacheline_sizes(void)
 +{
 +size_t len = 4;
 +unsigned cacheline;
 +
 +sysctlbyname (machdep.cacheline_size, cacheline, len, NULL, 0);

Error handling missing.

 +
 +qemu_cache_conf.dcache_bsize = cacheline;
 +qemu_cache_conf.icache_bsize = cacheline;
 +}
 +#endif
 +
  #ifdef __linux__
  void qemu_cache_utils_init(char **envp)
  {
 
 

-- 
mailto:av1...@comtv.ru




Re: [Qemu-devel] [PATCH 1/3] Add FreeBSD/ppc host ppc_init_cacheline_sizes() implementation.

2010-02-14 Thread malc
On Sun, 14 Feb 2010, Juergen Lock wrote:

 Submitted by: Andreas Tobler andre...@fgznet.ch
 
 Signed-off-by: Juergen Lock n...@jelal.kn-bremen.de
 
 --- a/cache-utils.c
 +++ b/cache-utils.c
 @@ -57,6 +57,23 @@
  }
  #endif
  
 +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)

__FreeBSD_kernel__ is for something like Debian/kFreeBSD?

 +#include stdio.h
 +#include sys/types.h
 +#include sys/sysctl.h
 +
 +static void ppc_init_cacheline_sizes(void)
 +{
 +size_t len = 4;
 +unsigned cacheline;
 +
 +sysctlbyname (machdep.cacheline_size, cacheline, len, NULL, 0);
 +
 +qemu_cache_conf.dcache_bsize = cacheline;
 +qemu_cache_conf.icache_bsize = cacheline;
 +}
 +#endif
 +
  #ifdef __linux__
  void qemu_cache_utils_init(char **envp)
  {
 
 

-- 
mailto:av1...@comtv.ru




[Qemu-devel] EHCI support in QEMU

2010-02-14 Thread Taimoor Mirza

Hi all,

 

I downloaded version 0.12.2 of QEMU and I am unable to find EHCI support in it. 
Does QEMU support EHCI emulation? Do I need to download some other patch for 
it? QEMU documentation also does not tell anything about EHCI.

 

-Taimoor
  
_
Hotmail: Trusted email with powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969

[Qemu-devel] Re: [PATCH 1/3] qemu-kvm: Wrap phys_ram_dirty with additional inline functions.

2010-02-14 Thread Yoshiaki Tamura

Avi Kivity wrote:

On 02/12/2010 04:08 AM, OHMURA Kei wrote:

Why do you need a counter? It may be sufficient to set a single bit.
This reduces the memory overhead and perhaps cache thrashing.

Thanks for looking into this. I agree with your opinion.

Our motivation here is to skip traveling when the dirty bitmap is
really sparse
or dense, so either setting a bit or counting up would be fine.

There is one advantage to the counter approach that we can make this
large
traveling granularity flexible. In case of the bit approach, the maximum
granularity is limited to HOST_LONG_BITS. If you think this
flexibility is to
be useless, we would take the bit approach.


The bit approach can be used for any packing ratio; for example you can
pack 64 pages in a single bit. The rule is that if one or more pages is
dirty, the bit is set; otherwise it is clear. This makes clearing a
single page expensive (you have to examine the state of 63 other pages)
but IIRC we always clear in ranges, so apart from the edges, you can use
a memset.


Sounds good.
If we could extend the packing ratio to kvm (in kernel),
it would be more efficient.


By the way, this is about filling the gap of the dirty bitmap management
between kvm and qemu. Do you think we should set a bit when qemu's
phys_ram_dirty is 0xff or !0?

Radically, if we could have a bit-based phys_ram_dirty_by_word, we may
just OR
the dirty bitmap of kvm with qemu in kvm_get_dirty_pages_log_range()...


The problem is that the qemu uses the dirty information for at least
three different purposes: live migration, vga updates, and tcg
self-modifying code. But I think that's solvable: keep a separate bitmap
for each purpose, and OR the kvm bitmap into any used qemu bitmap
whenever we get it from the kernel.

That has many advantages; foremost, when vnc is not connected and we
aren't live migrating, we can drop all of the bitmaps and save some
memory. If you can make that work I think that's best.


Would be happy to do it.
We were also thinking that approach originally, but hesitating because the 
changes might be radical.  I hope this plan is fine for upstream qemu too.





[Qemu-devel] [PATCH] pcnet APROMWE bit location

2010-02-14 Thread Chris Kilgour
I don't subscribe to the list, so please excuse any breach of etiquette. 

According to AMD document 21485D pp.141, APROMWE is bit 8 of BCR2.

Signed-off-by: Christopher Kilgour techie at whiterocker.com
---

diff --git a/hw/pcnet.c b/hw/pcnet.c
index 44b5b31..f889898 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -1601,7 +1601,7 @@ static void pcnet_aprom_writeb(void *opaque,
uint32_t addr
 printf(pcnet_aprom_writeb addr=0x%08x val=0x%02x\n, addr, val);
 #endif
 /* Check APROMWE bit to enable write access */
-if (pcnet_bcr_readw(s,2)  0x80)
+if (pcnet_bcr_readw(s,2)  0x100)
 s-prom[addr  15] = val;
 }





[Qemu-devel] Re: [PATCH v2] qemu-kvm: Speed up of the dirty-bitmap-traveling

2010-02-14 Thread OHMURA Kei
dirty-bitmap-traveling is carried out by byte size in qemu-kvm.c.
But We think that dirty-bitmap-traveling by long size is faster than by byte
size especially when most of memory is not dirty.

Signed-off-by: OHMURA Kei ohmura@lab.ntt.co.jp
---
 bswap.h|2 ++
 qemu-kvm.c |   31 ---
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/bswap.h b/bswap.h
index 4558704..1f87e6d 100644
--- a/bswap.h
+++ b/bswap.h
@@ -205,8 +205,10 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
 
 #ifdef HOST_WORDS_BIGENDIAN
 #define cpu_to_32wu cpu_to_be32wu
+#define leul_to_cpu(v) le ## HOST_LONG_BITS ## _to_cpu(v)
 #else
 #define cpu_to_32wu cpu_to_le32wu
+#define leul_to_cpu(v) (v)
 #endif
 
 #undef le_bswap
diff --git a/qemu-kvm.c b/qemu-kvm.c
index a305907..6952aa5 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -2434,31 +2434,32 @@ int kvm_physical_memory_set_dirty_tracking(int enable)
 
 /* get kvm's dirty pages bitmap and update qemu's */
 static int kvm_get_dirty_pages_log_range(unsigned long start_addr,
- unsigned char *bitmap,
+ unsigned long *bitmap,
  unsigned long offset,
  unsigned long mem_size)
 {
-unsigned int i, j, n = 0;
-unsigned char c;
-unsigned long page_number, addr, addr1;
+unsigned int i, j;
+unsigned long page_number, addr, addr1, c;
 ram_addr_t ram_addr;
-unsigned int len = ((mem_size / TARGET_PAGE_SIZE) + 7) / 8;
+unsigned int len = ((mem_size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) /
+HOST_LONG_BITS;
 
 /* 
  * bitmap-traveling is faster than memory-traveling (for addr...) 
  * especially when most of the memory is not dirty.
  */
 for (i = 0; i  len; i++) {
-c = bitmap[i];
-while (c  0) {
-j = ffsl(c) - 1;
-c = ~(1u  j);
-page_number = i * 8 + j;
-addr1 = page_number * TARGET_PAGE_SIZE;
-addr = offset + addr1;
-ram_addr = cpu_get_physical_page_desc(addr);
-cpu_physical_memory_set_dirty(ram_addr);
-n++;
+if (bitmap[i] != 0) {
+c = leul_to_cpu(bitmap[i]);
+do {
+j = ffsl(c) - 1;
+c = ~(1ul  j);
+page_number = i * HOST_LONG_BITS + j;
+addr1 = page_number * TARGET_PAGE_SIZE;
+addr = offset + addr1;
+ram_addr = cpu_get_physical_page_desc(addr);
+cpu_physical_memory_set_dirty(ram_addr);
+} while (c != 0);
 }
 }
 return 0;
-- 
1.6.3.3