[Qemu-devel] [Bug] qemu_memalign not matched with qemu_free

2008-01-23 Thread TeLeMan

qemu_memalign was introduced after this patch:
http://www.nabble.com/forum/ViewPost.jtp?post=14488239&framed=y

But the "free" function was qemu_free yet, the correct function should be
qemu_vfree.

This bug will lead to heap corrupted.
-- 
View this message in context: 
http://www.nabble.com/-Bug--qemu_memalign-not-matched-with-qemu_free-tp15059500p15059500.html
Sent from the QEMU - Dev mailing list archive at Nabble.com.





[Qemu-devel] [PATCH] hw/sun4m.c fix power addresses

2008-01-23 Thread Robert Reif


diff -p -u -r1.81 sun4m.c
--- hw/sun4m.c  17 Jan 2008 21:04:16 -  1.81
+++ hw/sun4m.c  24 Jan 2008 05:06:38 -
@@ -687,7 +687,7 @@ static const struct hwdef hwdefs[] = {
 .dma_base = 0x7840,
 .esp_base = 0x7880,
 .le_base  = 0x78c0,
-.power_base   = 0x7a00,
+.power_base   = 0x7191,
 .ecc_base = -1,
 .sun4c_intctl_base  = -1,
 .sun4c_counter_base = -1,
@@ -727,7 +727,7 @@ static const struct hwdef hwdefs[] = {
 .dma_base = 0xef040ULL,
 .esp_base = 0xef080ULL,
 .le_base  = 0xef0c0ULL,
-.power_base   = 0xefa00ULL,
+.power_base   = 0xff1a01000ULL,
 .ecc_base = 0xfULL,
 .ecc_version  = 0x1000, // version 0, implementation 1
 .sun4c_intctl_base  = -1,
@@ -811,7 +811,7 @@ static const struct hwdef hwdefs[] = {
 .dma_base = 0xef040ULL,
 .esp_base = 0xef080ULL,
 .le_base  = 0xef0c0ULL,
-.power_base   = 0xefa00ULL,
+.power_base   = 0xff1a01000ULL,
 .ecc_base = 0xfULL,
 .ecc_version  = 0x2000, // version 0, implementation 2
 .sun4c_intctl_base  = -1,


[Qemu-devel] vgabios-cirrus.bin header problems

2008-01-23 Thread Myles Watson
I've been trying to use qemu with coreboot (linuxbios v3), but it
complains about vgabios-cirrus.bin not matching the device ids.

It worked for someone else, and they sent me their vgabios-cirrus.bin,
which is different from mine, even though we both downloaded tarballs
of 0.9.0.  The broken one is included in 0.9.1 as well.

I've included the hexdumps.  As you can see, in
vgabios-cirrus.bin.new, "Plex86/Bochs VGABios " is written over the
part of the header that points to the data header. It's 0x0038 in
vgabios-cirrus.bin.works and 0x736f ("os") in vgabios-cirrus.bin.new.

I've downloaded every version of vgabios from nongnu, but they all
have the same problem.  Can someone help?

Thanks,
Myles

[EMAIL PROTECTED] hexdump -C ../../qemu/BIOS/vgabios-cirrus.bin.new | head -n 20
  55 aa 45 e9 ed 00 50 6c  65 78 38 36 2f 42 6f 63  |U.E...Plex86/Boc|
0010  68 73 20 56 47 41 42 69  6f 73 20 00 00 00 49 42  |hs VGABios ...IB|
0020  4d 00 63 75 72 72 65 6e  74 2d 63 76 73 20 31 34  |M.current-cvs 14|
0030  20 4a 75 6e 20 32 30 30  36 0a 0d 00 28 43 29 20  | Jun 2006...(C) |
0040  32 30 30 33 20 74 68 65  20 4c 47 50 4c 20 56 47  |2003 the LGPL VG|
0050  41 42 69 6f 73 20 64 65  76 65 6c 6f 70 65 72 73  |ABios developers|
0060  20 54 65 61 6d 0a 0d 00  54 68 69 73 20 56 47 41  | Team...This VGA|
0070  2f 56 42 45 20 42 69 6f  73 20 69 73 20 72 65 6c  |/VBE Bios is rel|
0080  65 61 73 65 64 20 75 6e  64 65 72 20 74 68 65 20  |eased under the |
0090  47 4e 55 20 4c 47 50 4c  0a 0d 0a 0d 00 50 6c 65  |GNU LGPL.Ple|
00a0  61 73 65 20 76 69 73 69  74 20 3a 0a 0d 20 2e 20  |ase visit :.. . |
00b0  68 74 74 70 3a 2f 2f 62  6f 63 68 73 2e 73 6f 75  |http://bochs.sou|
00c0  72 63 65 66 6f 72 67 65  2e 6e 65 74 0a 0d 20 2e  |rceforge.net.. .|
00d0  20 68 74 74 70 3a 2f 2f  77 77 77 2e 6e 6f 6e 67  | http://www.nong|
00e0  6e 75 2e 6f 72 67 2f 76  67 61 62 69 6f 73 0a 0d  |nu.org/vgabios..|
00f0  0a 0d 00 e8 16 34 e8 72  34 1e 31 c0 8e d8 b8 1d  |.4.r4.1.|
0100  01 a3 40 00 b8 00 c0 a3  42 00 1f e8 a6 81 e8 ae  |[EMAIL PROTECTED]|
0110  34 b8 03 00 cd 10 e8 a7  34 e8 cf 81 cb 9c 80 fc  |4...4...|
0120  0f 75 05 e8 86 5f eb 7c  80 fc 1a 75 05 e8 a9 6a  |.u..._.|...u...j|
0130  eb 72 80 fc 0b 75 05 e8  f3 56 eb 68 3d 03 11 75  |.r...u...V.h=..u|

[EMAIL PROTECTED] hexdump -C ../../qemu/BIOS/vgabios-cirrus.bin.works | head -n 
20
  55 aa 46 e9 1b 01 00 00  00 00 00 00 00 00 00 00  |U.F.|
0010  00 00 00 00 00 00 00 00  38 00 00 00 00 00 49 42  |8.IB|
0020  4d 00 50 6c 65 78 38 36  2f 42 6f 63 68 73 20 56  |M.Plex86/Bochs V|
0030  47 41 42 69 6f 73 20 00  50 43 49 52 13 10 b8 00  |GABios .PCIR|
0040  00 00 18 00 00 00 00 03  46 00 01 00 00 80 00 00  |F...|
0050  63 75 72 72 65 6e 74 2d  63 76 73 20 31 32 20 4d  |current-cvs 12 M|
0060  61 72 20 32 30 30 37 0a  0d 00 28 43 29 20 32 30  |ar 2007...(C) 20|
0070  30 33 20 74 68 65 20 4c  47 50 4c 20 56 47 41 42  |03 the LGPL VGAB|
0080  69 6f 73 20 64 65 76 65  6c 6f 70 65 72 73 20 54  |ios developers T|
0090  65 61 6d 0a 0d 00 54 68  69 73 20 56 47 41 2f 56  |eam...This VGA/V|
00a0  42 45 20 42 69 6f 73 20  69 73 20 72 65 6c 65 61  |BE Bios is relea|
00b0  73 65 64 20 75 6e 64 65  72 20 74 68 65 20 47 4e  |sed under the GN|
00c0  55 20 4c 47 50 4c 0a 0d  0a 0d 00 50 6c 65 61 73  |U LGPL.Pleas|
00d0  65 20 76 69 73 69 74 20  3a 0a 0d 20 2e 20 68 74  |e visit :.. . ht|
00e0  74 70 3a 2f 2f 62 6f 63  68 73 2e 73 6f 75 72 63  |tp://bochs.sourc|
00f0  65 66 6f 72 67 65 2e 6e  65 74 0a 0d 20 2e 20 68  |eforge.net.. . h|
0100  74 74 70 3a 2f 2f 77 77  77 2e 6e 6f 6e 67 6e 75  |ttp://www.nongnu|
0110  2e 6f 72 67 2f 76 67 61  62 69 6f 73 0a 0d 0a 0d  |.org/vgabios|
0120  00 e8 16 34 e8 72 34 1e  31 c0 8e d8 b8 4b 01 a3  |...4.r4.1K..|
0130  40 00 b8 00 c0 a3 42 00  1f e8 ce 81 e8 ae 34 b8  |@.B...4.|




[Qemu-devel] [PATCH] fix SVM event injection

2008-01-23 Thread Bernhard Kauer
The SVM event injection mechanism for NMI and INTRs should not
be handled as software interrupts.


Bernhard Kauer
Index: target-i386/helper.c
--- target-i386/helper.c	24 Dec 2007 13:36:00 -	1.98
+++ target-i386/helper.c	23 Jan 2008 22:37:49 -
@@ -4124,7 +4193,7 @@
 case SVM_EVTINJ_TYPE_INTR:
 env->exception_index = vector;
 env->error_code = event_inj_err;
-env->exception_is_int = 1;
+env->exception_is_int = 0;
 env->exception_next_eip = -1;
 if (loglevel & CPU_LOG_TB_IN_ASM)
 fprintf(logfile, "INTR");
@@ -4132,7 +4201,7 @@
 case SVM_EVTINJ_TYPE_NMI:
 env->exception_index = vector;
 env->error_code = event_inj_err;
-env->exception_is_int = 1;
+env->exception_is_int = 0;
 env->exception_next_eip = EIP;
 if (loglevel & CPU_LOG_TB_IN_ASM)
 fprintf(logfile, "NMI");


Re: [Qemu-devel] emulate the Intel-VT behavior on any type of CPU

2008-01-23 Thread Alexey Eremenko
Try: qemu-system-x86_64

By default, you use "qemu" which is a 32-bit emulator. I think SVM is
available only to 64-bit guests. The 64-bit emulator is named:
"qemu-system-x86_64", and don't worry, your CPU will work, despite
being 32-bit without SVM. 64-bit part is for guests, not for host.

I'm not sure if your guest OS also needs to be 64-bit, but it better be.

-- 
-Alexey Eremenko "Technologov"




Re: [Qemu-devel] emulate the Intel-VT behavior on any type of CPU

2008-01-23 Thread octane indice
En réponse à Alexander Graf <[EMAIL PROTECTED]> :
> >> He was talking about running SVM code in KQemu/KVM. It
> >>might work with kqemu 

No, I have a intel PIII CPU without vt extensions.

I want to test KVM.

My idea is to use a qemu machine emulating the VT instruction.

So, in the qemu machine, I could load KVM.

But it doesn't seem to work.

I downloaded a qemu-0.9.1, compiled it.

A cat /proc/cpuinfo inside qemu doesn't show me vmx nor svm.

Am I forgotting something?

Thanks

Eurolines : Voyagez au meilleur prix : http://www.alinto.com/pub/




Re: [Qemu-devel] [PATCH 0/5] SCSI passthrough cleanup

2008-01-23 Thread Fabrice Bellard
Two questions:

- Why do you use AIO ? If the Linux sg device supports selects, then
using the QEMU select() callback suffices.

- Why do you use a block device ?

Regards,

Fabrice.

Laurent Vivier wrote:
> This series of patches makes some cleanups in SCSI passthrough and
> add functionnalities.
> 
> [PATCH 1/5] reverse scsi-generic
> 
> Reverse previous implementation and restore block-raw-posix.c.
> 
> [PATCH 2/5] Move AIO
> 
> This patche moves raw AIO part from block-raw-posix.c to qemu-aio-raw.c.
> 
> [PATCH 3/5] Add block SG interface
> 
> This patch re-implement scsi-generic.c using a new block interface.
> 
> [PATCH 4/5] DVD movie support
> 
> This patch allows to read a protected/encrypted movie from a DVD.
> 
> [PATCH 5/5] SCSI device DMA split
> 
> This patch allows to split a READ or WRITE into several READ or WRITE.
> 
> Laurent
> 
> 
> 
> 
> 





Re: [Qemu-devel] qemu cpu-all.h cpu-exec.c qemu-doc.texi vl.c

2008-01-23 Thread Robert Reif

Thiemo Seufer wrote:


CVSROOT:/sources/qemu
Module name:qemu
Changes by: Thiemo Seufer08/01/23 19:01:12

Modified files:
	.  : cpu-all.h cpu-exec.c qemu-doc.texi vl.c 


Log message:
Add option to disable TB cache, by Herve Poussineau.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/cpu-all.h?cvsroot=qemu&r1=1.81&r2=1.82
http://cvs.savannah.gnu.org/viewcvs/qemu/cpu-exec.c?cvsroot=qemu&r1=1.130&r2=1.131
http://cvs.savannah.gnu.org/viewcvs/qemu/qemu-doc.texi?cvsroot=qemu&r1=1.182&r2=1.183
http://cvs.savannah.gnu.org/viewcvs/qemu/vl.c?cvsroot=qemu&r1=1.400&r2=1.401



 


This gives the following compile errror:

gcc -Wall -O2 -g -fno-strict-aliasing -fomit-frame-pointer -I. -I.. 
-I/home/wine/qemu/target-i386 -I/home/wine/qemu -MMD -MP -DNEED_CPU_H 
-I/home/wine/qemu/linux-user -I/home/wine/qemu/linux-user/i386 
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 
-I/home/wine/qemu/fpu -DHAS_AUDIO -DHAS_AUDIO_CHOICE 
-I/home/wine/qemu/slirp-c -o cpu-exec.o /home/wine/qemu/cpu-exec.c

/home/wine/qemu/cpu-exec.c: In function `cmp1':
/home/wine/qemu/cpu-exec.c:143: unable to find a register to spill in 
class `DIREG'

/home/wine/qemu/cpu-exec.c:143: this is the insn:
(insn 21 78 23 (parallel[
   (set (reg:SI 2 ecx [64])
   (unspec:SI[
   (mem:BLK (reg/f:SI 1 edx [66]) [0 A8])
   (reg:QI 0 al [68])
   (const_int 1 [0x1])
   (reg:SI 2 ecx [67])
   ]  0))
   (use (reg:SI 19 dirflag))
   (clobber (reg/f:SI 1 edx [66]))
   (clobber (reg:CC 17 flags))
   ] ) 623 {strlenqi_1} (insn_list 15 (insn_list 17 (insn_list 19 
(insn_list 20 (nil)

   (expr_list:REG_DEAD (reg:SI 19 dirflag)
   (expr_list:REG_DEAD (reg:SI 2 ecx [67])
   (expr_list:REG_DEAD (reg:QI 0 al [68])
   (expr_list:REG_DEAD (reg/f:SI 1 edx [66])
   (expr_list:REG_UNUSED (reg/f:SI 1 edx [66])
   (expr_list:REG_UNUSED (reg:CC 17 flags)
   (nil
/home/wine/qemu/cpu-exec.c:143: confused by earlier errors, bailing out
make[1]: *** [cpu-exec.o] Error 1
make[1]: Leaving directory `/home/wine/qemu/i386-linux-user'
make: *** [subdir-i386-linux-user] Error 2






[Qemu-devel] qemu cpu-all.h cpu-exec.c qemu-doc.texi vl.c

2008-01-23 Thread Thiemo Seufer
CVSROOT:/sources/qemu
Module name:qemu
Changes by: Thiemo Seufer  08/01/23 19:01:12

Modified files:
.  : cpu-all.h cpu-exec.c qemu-doc.texi vl.c 

Log message:
Add option to disable TB cache, by Herve Poussineau.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/cpu-all.h?cvsroot=qemu&r1=1.81&r2=1.82
http://cvs.savannah.gnu.org/viewcvs/qemu/cpu-exec.c?cvsroot=qemu&r1=1.130&r2=1.131
http://cvs.savannah.gnu.org/viewcvs/qemu/qemu-doc.texi?cvsroot=qemu&r1=1.182&r2=1.183
http://cvs.savannah.gnu.org/viewcvs/qemu/vl.c?cvsroot=qemu&r1=1.400&r2=1.401




[Qemu-devel] [PATCH 2/5] Move AIO

2008-01-23 Thread Laurent Vivier

This patche moves raw AIO part from block-raw-posix.c to qemu-aio-raw.c to
be able to use raw AIO from other files.

Laurent
---
 Makefile  |2 
 Makefile.target   |2 
 block-raw-posix.c |  205 ++---
 qemu-aio-posix.c  |  241 ++
 qemu-aio-posix.h  |   39 
 5 files changed, 293 insertions(+), 196 deletions(-)

Index: qemu/Makefile.target
===
--- qemu.orig/Makefile.target   2008-01-23 09:18:17.0 +0100
+++ qemu/Makefile.target2008-01-23 09:19:30.0 +0100
@@ -398,7 +398,7 @@ VL_OBJS=vl.o osdep.o monitor.o pci.o loa
 ifdef CONFIG_WIN32
 VL_OBJS+=block-raw-win32.o
 else
-VL_OBJS+=block-raw-posix.o
+VL_OBJS+=block-raw-posix.o qemu-aio-posix.o
 endif
 
 ifdef CONFIG_ALSA
Index: qemu/block-raw-posix.c
===
--- qemu.orig/block-raw-posix.c 2008-01-23 09:19:16.0 +0100
+++ qemu/block-raw-posix.c  2008-01-23 09:19:30.0 +0100
@@ -28,7 +28,7 @@
 #endif
 #include "block_int.h"
 #include 
-#include 
+#include "qemu-aio-posix.h"
 
 #ifdef CONFIG_COCOA
 #include 
@@ -75,7 +75,7 @@
 #define FD_OPEN_TIMEOUT 1000
 
 typedef struct BDRVRawState {
-int fd;
+int fd;/* must be the first field for qemu-aio-posix.c */
 int type;
 unsigned int lseek_err_cnt;
 #if defined(__linux__)
@@ -233,180 +233,18 @@ label__raw_write__success:
 /***/
 /* Unix AIO using POSIX AIO */
 
-typedef struct RawAIOCB {
-BlockDriverAIOCB common;
-struct aiocb aiocb;
-struct RawAIOCB *next;
-} RawAIOCB;
-
-static int aio_sig_num = SIGUSR2;
-static RawAIOCB *first_aio; /* AIO issued */
-static int aio_initialized = 0;
-
-static void aio_signal_handler(int signum)
-{
-#ifndef QEMU_IMG
-CPUState *env = cpu_single_env;
-if (env) {
-/* stop the currently executing cpu because a timer occured */
-cpu_interrupt(env, CPU_INTERRUPT_EXIT);
-#ifdef USE_KQEMU
-if (env->kqemu_enabled) {
-kqemu_cpu_interrupt(env);
-}
-#endif
-}
-#endif
-}
-
-void qemu_aio_init(void)
-{
-struct sigaction act;
-
-aio_initialized = 1;
-
-sigfillset(&act.sa_mask);
-act.sa_flags = 0; /* do not restart syscalls to interrupt select() */
-act.sa_handler = aio_signal_handler;
-sigaction(aio_sig_num, &act, NULL);
-
-#if defined(__GLIBC__) && defined(__linux__)
-{
-/* XXX: aio thread exit seems to hang on RedHat 9 and this init
-   seems to fix the problem. */
-struct aioinit ai;
-memset(&ai, 0, sizeof(ai));
-ai.aio_threads = 1;
-ai.aio_num = 1;
-ai.aio_idle_time = 365 * 10;
-aio_init(&ai);
-}
-#endif
-}
-
-void qemu_aio_poll(void)
-{
-RawAIOCB *acb, **pacb;
-int ret;
-
-for(;;) {
-pacb = &first_aio;
-for(;;) {
-acb = *pacb;
-if (!acb)
-goto the_end;
-ret = aio_error(&acb->aiocb);
-if (ret == ECANCELED) {
-/* remove the request */
-*pacb = acb->next;
-qemu_aio_release(acb);
-} else if (ret != EINPROGRESS) {
-/* end of aio */
-if (ret == 0) {
-ret = aio_return(&acb->aiocb);
-if (ret == acb->aiocb.aio_nbytes)
-ret = 0;
-else
-ret = -EINVAL;
-} else {
-ret = -ret;
-}
-/* remove the request */
-*pacb = acb->next;
-/* call the callback */
-acb->common.cb(acb->common.opaque, ret);
-qemu_aio_release(acb);
-break;
-} else {
-pacb = &acb->next;
-}
-}
-}
- the_end: ;
-}
-
-/* Wait for all IO requests to complete.  */
-void qemu_aio_flush(void)
-{
-qemu_aio_wait_start();
-qemu_aio_poll();
-while (first_aio) {
-qemu_aio_wait();
-}
-qemu_aio_wait_end();
-}
-
-/* wait until at least one AIO was handled */
-static sigset_t wait_oset;
-
-void qemu_aio_wait_start(void)
-{
-sigset_t set;
-
-if (!aio_initialized)
-qemu_aio_init();
-sigemptyset(&set);
-sigaddset(&set, aio_sig_num);
-sigprocmask(SIG_BLOCK, &set, &wait_oset);
-}
-
-void qemu_aio_wait(void)
-{
-sigset_t set;
-int nb_sigs;
-
-#ifndef QEMU_IMG
-if (qemu_bh_poll())
-return;
-#endif
-sigemptyset(&set);
-sigaddset(&set, aio_sig_num);
-sigwait(&set, &nb_sigs);
-qemu_aio_poll();
-}
-
-void qemu_aio_wait_end(void)
-{
-sigprocmask(SIG_SETMASK, &wait_oset, NULL);
-}
-
-static RawAIOCB *raw_aio_setup(BlockDriverState *bs,
+static BlockDriverAIOCB *raw_aio_read(BlockDrive

[Qemu-devel] [PATCH 1/5] reverse scsi-generic

2008-01-23 Thread Laurent Vivier

This patch removes modifications in block interface introduced by the 
scsi-generic implementation, and disables scsi-generic support.

Files restored are:
block-raw-posix.c   revision 1.2
block.c revision 1.52
block.h revision 1.5
block_int.h revision 1.15

Laurent
---
 block-raw-posix.c |   23 +++
 block.c   |   16 
 block.h   |2 --
 block_int.h   |4 
 hw/scsi-generic.c |3 ++-
 5 files changed, 5 insertions(+), 43 deletions(-)

Index: qemu/block.c
===
--- qemu.orig/block.c   2008-01-23 09:18:17.0 +0100
+++ qemu/block.c2008-01-23 09:19:16.0 +0100
@@ -786,11 +786,6 @@ int bdrv_is_read_only(BlockDriverState *
 return bs->read_only;
 }
 
-int bdrv_is_sg(BlockDriverState *bs)
-{
-return bs->sg;
-}
-
 /* XXX: no longer used */
 void bdrv_set_change_cb(BlockDriverState *bs,
 void (*change_cb)(void *opaque), void *opaque)
@@ -1399,14 +1394,3 @@ void bdrv_set_locked(BlockDriverState *b
 drv->bdrv_set_locked(bs, locked);
 }
 }
-
-/* needed for generic scsi interface */
-
-int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
-{
-BlockDriver *drv = bs->drv;
-
-if (drv && drv->bdrv_ioctl)
-return drv->bdrv_ioctl(bs, req, buf);
-return -ENOTSUP;
-}
Index: qemu/block.h
===
--- qemu.orig/block.h   2008-01-23 09:18:17.0 +0100
+++ qemu/block.h2008-01-23 09:19:16.0 +0100
@@ -119,7 +119,6 @@ int bdrv_get_type_hint(BlockDriverState 
 int bdrv_get_translation_hint(BlockDriverState *bs);
 int bdrv_is_removable(BlockDriverState *bs);
 int bdrv_is_read_only(BlockDriverState *bs);
-int bdrv_is_sg(BlockDriverState *bs);
 int bdrv_is_inserted(BlockDriverState *bs);
 int bdrv_media_changed(BlockDriverState *bs);
 int bdrv_is_locked(BlockDriverState *bs);
@@ -149,7 +148,6 @@ int bdrv_snapshot_delete(BlockDriverStat
 int bdrv_snapshot_list(BlockDriverState *bs,
QEMUSnapshotInfo **psn_info);
 char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn);
-int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf);
 
 char *get_human_readable_size(char *buf, int buf_size, int64_t size);
 int path_is_absolute(const char *path);
Index: qemu/block_int.h
===
--- qemu.orig/block_int.h   2008-01-23 09:18:17.0 +0100
+++ qemu/block_int.h2008-01-23 09:19:16.0 +0100
@@ -82,9 +82,6 @@ struct BlockDriver {
 int (*bdrv_eject)(BlockDriverState *bs, int eject_flag);
 int (*bdrv_set_locked)(BlockDriverState *bs, int locked);
 
-/* to control generic scsi devices */
-int (*bdrv_ioctl)(BlockDriverState *bs, unsigned long int req, void *buf);
-
 BlockDriverAIOCB *free_aiocb;
 struct BlockDriver *next;
 };
@@ -96,7 +93,6 @@ struct BlockDriverState {
 int removable; /* if true, the media can be removed */
 int locked;/* if true, the media cannot temporarily be ejected */
 int encrypted; /* if true, the media is encrypted */
-int sg;/* if true, the device is a /dev/sg* */
 /* event callback when inserting/removing */
 void (*change_cb)(void *opaque);
 void *change_opaque;
Index: qemu/block-raw-posix.c
===
--- qemu.orig/block-raw-posix.c 2008-01-23 09:18:17.0 +0100
+++ qemu/block-raw-posix.c  2008-01-23 09:19:16.0 +0100
@@ -151,7 +151,7 @@ static int raw_pread(BlockDriverState *b
 if (ret < 0)
 return ret;
 
-if (offset >= 0 && lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
+if (lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
 ++(s->lseek_err_cnt);
 if(s->lseek_err_cnt <= 10) {
 DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
@@ -204,7 +204,7 @@ static int raw_pwrite(BlockDriverState *
 if (ret < 0)
 return ret;
 
-if (offset >= 0 && lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
+if (lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
 ++(s->lseek_err_cnt);
 if(s->lseek_err_cnt) {
 DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %" PRId64 ", %p, %d) [%"
@@ -387,10 +387,7 @@ static RawAIOCB *raw_aio_setup(BlockDriv
 acb->aiocb.aio_sigevent.sigev_signo = aio_sig_num;
 acb->aiocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
 acb->aiocb.aio_buf = buf;
-if (nb_sectors < 0)
-acb->aiocb.aio_nbytes = -nb_sectors;
-else
-acb->aiocb.aio_nbytes = nb_sectors * 512;
+acb->aiocb.aio_nbytes = nb_sectors * 512;
 acb->aiocb.aio_offset = sector_num * 512;
 acb->next = first_aio;
 first_aio = acb;
@@ -682,8 +679,6 @@ static int hdev_open(BlockDriverState *b
 s->fd_open_flags 

[Qemu-devel] [PATCH 3/5] Add block SG interface

2008-01-23 Thread Laurent Vivier

This patch re-implement scsi-generic.c using a new block interface called
block-sg.c instead of block-raw-posix.c.
It adds a new interface (bdrv_execute) allowing to send command to the device.

Laurent
---
 Makefile  |2 
 Makefile.target   |2 
 block-sg.c|  194 ++
 block-sg.h|   18 +
 block.c   |   21 +
 block.h   |4 +
 block_int.h   |4 +
 hw/scsi-generic.c |  176 +---
 8 files changed, 303 insertions(+), 118 deletions(-)

Index: qemu/block.c
===
--- qemu.orig/block.c   2008-01-23 16:02:32.0 +0100
+++ qemu/block.c2008-01-23 16:43:01.0 +0100
@@ -126,13 +126,14 @@ void path_combine(char *dest, int dest_s
 
 static void bdrv_register(BlockDriver *bdrv)
 {
-if (!bdrv->bdrv_aio_read) {
+if (!bdrv->bdrv_aio_read && !bdrv->bdrv_execute) {
 /* add AIO emulation layer */
 bdrv->bdrv_aio_read = bdrv_aio_read_em;
 bdrv->bdrv_aio_write = bdrv_aio_write_em;
 bdrv->bdrv_aio_cancel = bdrv_aio_cancel_em;
 bdrv->aiocb_size = sizeof(BlockDriverAIOCBSync);
-} else if (!bdrv->bdrv_read && !bdrv->bdrv_pread) {
+} else if (!bdrv->bdrv_read && !bdrv->bdrv_pread &&
+   !bdrv->bdrv_execute) {
 /* add synchronous IO emulation layer */
 bdrv->bdrv_read = bdrv_read_em;
 bdrv->bdrv_write = bdrv_write_em;
@@ -267,6 +268,8 @@ static BlockDriver *find_image_format(co
 struct stat st;
 if (stat(filename, &st) >= 0 &&
 (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
+if ((st.st_rdev >> 8) == 0x15) /* SG device */
+return &bdrv_sg_device;
 return &bdrv_host_device;
 }
 }
@@ -1289,6 +1292,7 @@ void bdrv_init(void)
 bdrv_register(&bdrv_vvfat);
 bdrv_register(&bdrv_qcow2);
 bdrv_register(&bdrv_parallels);
+bdrv_register(&bdrv_sg_device);
 }
 
 void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,
@@ -1394,3 +1398,16 @@ void bdrv_set_locked(BlockDriverState *b
 drv->bdrv_set_locked(bs, locked);
 }
 }
+
+/* send a command to a device, needed for generic scsi interface */
+
+int bdrv_execute(BlockDriverState *bs, void *request,
+ BlockDriverCompletionFunc *complete)
+{
+   BlockDriver *drv = bs->drv;
+
+if (drv && drv->bdrv_execute) {
+return drv->bdrv_execute(bs, request, complete);
+}
+return -ENOTSUP;
+}
Index: qemu/block.h
===
--- qemu.orig/block.h   2008-01-23 16:02:32.0 +0100
+++ qemu/block.h2008-01-23 16:02:32.0 +0100
@@ -16,6 +16,7 @@ extern BlockDriver bdrv_vpc;
 extern BlockDriver bdrv_vvfat;
 extern BlockDriver bdrv_qcow2;
 extern BlockDriver bdrv_parallels;
+extern BlockDriver bdrv_sg_device;
 
 typedef struct BlockDriverInfo {
 /* in bytes, 0 if irrelevant */
@@ -148,6 +149,9 @@ int bdrv_snapshot_delete(BlockDriverStat
 int bdrv_snapshot_list(BlockDriverState *bs,
QEMUSnapshotInfo **psn_info);
 char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn);
+int bdrv_execute(BlockDriverState *bs, void *request,
+ BlockDriverCompletionFunc *complete);
+
 
 char *get_human_readable_size(char *buf, int buf_size, int64_t size);
 int path_is_absolute(const char *path);
Index: qemu/block-sg.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ qemu/block-sg.c 2008-01-23 16:41:58.0 +0100
@@ -0,0 +1,194 @@
+/*
+ * sg driver for RAW files
+ *
+ * Copyright (c) 2008 Bull S.A.S.
+ * Based on code by Fabrice Bellard
+ *
+ * Written by Laurent Vivier <[EMAIL PROTECTED]>
+ *
+ * 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
+

[Qemu-devel] [PATCH 4/5] DVD movie support

2008-01-23 Thread Laurent Vivier

This patch allows to read a protected/encrypted movie from a DVD.
(With a Movie Player having the key to decode it, tested with powerDVD)

Laurent
---
 hw/scsi-generic.c |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Index: qemu/hw/scsi-generic.c
===
--- qemu.orig/hw/scsi-generic.c 2008-01-23 14:03:01.0 +0100
+++ qemu/hw/scsi-generic.c  2008-01-23 14:03:02.0 +0100
@@ -46,9 +46,12 @@ do { fprintf(stderr, "scsi-generic: " fm
 #include 
 #include "block-sg.h"
 
+#define BLANK 0xa1
+#define SEND_KEY 0xa3
+#define REPORT_KEY 0xa4
 #define LOAD_UNLOAD 0xa6
+#define READ_DVD_STRUCTURE 0xad
 #define SET_CD_SPEED 0xbb
-#define BLANK 0xa1
 
 #define SCSI_CMD_BUF_SIZE 16
 #define SCSI_SENSE_BUF_SIZE 32
@@ -398,6 +401,12 @@ static int scsi_length(uint8_t *cmd, int
 case READ_12:
 *len *= blocksize;
 break;
+  case READ_DVD_STRUCTURE:
+  case SEND_KEY:
+  case REPORT_KEY:
+  *len &= 0x;
+  break;
+
 }
 return 0;
 }
@@ -435,6 +444,7 @@ static int is_write(int command)
 case MEDIUM_SCAN:
 case SEND_VOLUME_TAG:
 case WRITE_LONG_2:
+case SEND_KEY:
 return 1;
 }
 return 0;





[Qemu-devel] [PATCH 5/5] SCSI device DMA split

2008-01-23 Thread Laurent Vivier

With some emulated SCSI devices, like usb-storage or ide-scsi, DMA transfers
are limited to 64 kiB or 32 kiB.
This patch allows to split a READ or WRITE into several READ or WRITE.

Laurent
---
 block-sg.c|1 
 hw/scsi-generic.c |  110 +++---
 2 files changed, 105 insertions(+), 6 deletions(-)

Index: qemu/hw/scsi-generic.c
===
--- qemu.orig/hw/scsi-generic.c 2008-01-23 15:29:26.0 +0100
+++ qemu/hw/scsi-generic.c  2008-01-23 15:29:26.0 +0100
@@ -60,6 +60,8 @@ do { fprintf(stderr, "scsi-generic: " fm
 #define MAX_UINT ((unsigned int)-1)
 #endif
 
+#define MAX_CHUNK 65536
+
 typedef struct SCSIRequest {
 SGRequest sg;
 struct SCSIRequest *next;
@@ -70,6 +72,8 @@ typedef struct SCSIRequest {
 uint8_t *buf;
 int buflen;
 int len;
+int remaining;
+int offset;
 } SCSIRequest;
 
 struct SCSIDeviceState
@@ -81,6 +85,7 @@ struct SCSIDeviceState
 void *card;
 int driver_status;
 uint8_t sensebuf[SCSI_SENSE_BUF_SIZE];
+int max_chunk;
 };
 
 /* Global pool of SCSIRequest structures.  */
@@ -98,6 +103,7 @@ static SCSIRequest *scsi_new_request(SCS
 r->buf = NULL;
 r->buflen = 0;
 }
+r->offset = 0;
 r->dev = s;
 r->tag = tag;
 memset(r->cmd, 0, sizeof(r->cmd));
@@ -186,23 +192,93 @@ static void scsi_cancel_io(SCSIDevice *d
 }
 }
 
+static void scsi_cmd_next(uint8_t *cmd, uint32_t inc)
+{
+uint32_t addr;
+switch (cmd[0] >> 5) {
+case 0:
+addr = cmd[3] | (cmd[2] << 8);
+addr += inc;
+cmd[2] = addr >> 8;
+cmd[3] = addr;
+break;
+case 1:
+case 2:
+case 4:
+case 5:
+addr = cmd[5] | ((cmd[4] << 8) | ((cmd[3] << 16) | (cmd[2] << 24)));
+addr += inc;
+cmd[2] = addr >> 24;
+cmd[3] = addr >> 16;
+cmd[4] = addr >> 8;
+cmd[5] = addr;
+break;
+}
+}
+static void scsi_set_length(uint8_t *cmd, uint32_t len)
+{
+switch (cmd[0] >> 5) {
+case 0:
+cmd[4] = len;
+break;
+case 1:
+case 2:
+cmd[7] = (len >> 8);
+cmd[8] = len;
+break;
+case 4:
+cmd[10] = len >> 24;
+cmd[11] = len >> 16;
+cmd[12] = len >> 8;
+cmd[13] = len;
+break;
+case 5:
+cmd[6] = len >> 24;
+cmd[7] = len >> 16;
+cmd[8] = len >> 8;
+cmd[9] = len;
+break;
+}
+}
+
+
 static int execute_command(BlockDriverState *bdrv,
SCSIRequest *r, int direction,
BlockDriverCompletionFunc *complete)
 {
+int ret;
+SCSIDeviceState *s = r->dev;
+
+r->remaining = 0;
+retry:
+if (s->max_chunk && r->buflen > s->max_chunk) {
+r->remaining = r->buflen - s->max_chunk;
+scsi_set_length(r->cmd, s->max_chunk / s->blocksize);
+r->buflen = s->max_chunk;
+}
 memset(&r->sg, 0, sizeof(r->sg));
 r->sg.io_header.interface_id = 'S';
+r->sg.io_header.dxferp = r->buf + r->offset;
 r->sg.io_header.dxfer_direction = direction;
 r->sg.io_header.cmd_len = r->cmdlen;
-r->sg.io_header.mx_sb_len = sizeof(r->dev->sensebuf);
 r->sg.io_header.dxfer_len = r->buflen;
-r->sg.io_header.dxferp = r->buf;
+r->sg.io_header.mx_sb_len = sizeof(s->sensebuf);
+r->sg.io_header.sbp = s->sensebuf;
 r->sg.io_header.cmdp = r->cmd;
-r->sg.io_header.sbp = r->dev->sensebuf;
 r->sg.io_header.timeout = MAX_UINT;
 r->sg.io_header.flags |= SG_FLAG_DIRECT_IO;
 
-return bdrv_execute(bdrv, &r->sg, complete);
+ret = bdrv_execute(bdrv, &r->sg, complete);
+if (ret == -1 && errno == 12) {
+if (!s->max_chunk) {
+s->max_chunk = MAX_CHUNK;
+goto retry;
+} else if (s->max_chunk > s->blocksize) {
+s->max_chunk >>= 1;
+goto retry;
+}
+}
+return ret;
 }
 
 static void scsi_read_complete(void *request, int ret)
@@ -216,7 +292,18 @@ static void scsi_read_complete(void *req
 scsi_command_complete(r, ret);
 return;
 }
-len = r->sg.io_header.dxfer_len - r->sg.io_header.resid;
+r->offset += r->sg.io_header.dxfer_len - r->sg.io_header.resid;
+if (r->remaining != 0) {
+scsi_cmd_next(r->cmd, r->buflen / s->blocksize);
+scsi_set_length(r->cmd, r->remaining / s->blocksize);
+r->buflen = r->remaining;
+ret = execute_command(s->bdrv, r, SG_DXFER_FROM_DEV,
+  scsi_read_complete);
+if (ret == -1)
+scsi_command_complete(r, -EINVAL);
+return;
+}
+len = r->offset;
 DPRINTF("Data ready tag=0x%x len=%d\n", r->tag, len);
 
 r->len = -1;
@@ -263,12 +350,24 @@ static void scsi_read_data(SCSIDevice *d
 static void scsi_write_complete(void* request, int ret)
 {
 SCSIRequest* r = (SCSIRequest*)request;
+SCSID

[Qemu-devel] [PATCH 0/5] SCSI passthrough cleanup

2008-01-23 Thread Laurent Vivier

This series of patches makes some cleanups in SCSI passthrough and
add functionnalities.

[PATCH 1/5] reverse scsi-generic

Reverse previous implementation and restore block-raw-posix.c.

[PATCH 2/5] Move AIO

This patche moves raw AIO part from block-raw-posix.c to qemu-aio-raw.c.

[PATCH 3/5] Add block SG interface

This patch re-implement scsi-generic.c using a new block interface.

[PATCH 4/5] DVD movie support

This patch allows to read a protected/encrypted movie from a DVD.

[PATCH 5/5] SCSI device DMA split

This patch allows to split a READ or WRITE into several READ or WRITE.

Laurent





Re: [Qemu-devel] [PATCH][PPC] Use float32/64 instead of float/double

2008-01-23 Thread Aurelien Jarno
Aurelien Jarno a écrit :
> On Sun, Dec 30, 2007 at 06:32:45PM +0200, Blue Swirl wrote:
>> On 12/30/07, Aurelien Jarno <[EMAIL PROTECTED]> wrote:
>>> The patch below changes the float and double types into float32 and
>>> and float64 types in the PPC code. This doesn't change anything when
>>> using softfloat-native as the types are the same, but that helps
>>> compiling the PPC target with softfloat.
>> You could also consider replacing the unions with the common
>> definition CPU_DoubleU in cpu-all.h and also add CPU_FloatU.
> 
> Good idea. Please find and updated patch below.
> 
> 
> The patch below uses the float32 and float64 types instead of the float
> and double types in the PPC code. This doesn't change anything when
> using softfloat-native as the types are the same, but that helps 
> compiling the PPC target with softfloat.
> 
> It also defines a new union CPU_FloatU in addition to CPU_DoubleU, and
> use them instead of identical unions that are defined in numerous 
> places.
> 
>  cpu-all.h  |5 
>  target-ppc/op.c|   83 ++--
>  target-ppc/op_helper.c |  418 
> +++--
>  target-ppc/op_helper.h |  104 +++
>  target-ppc/op_helper_mem.h |   18 -
>  target-ppc/op_mem.h|   69 ++-
>  6 files changed, 240 insertions(+), 457 deletions(-)


Any news about this patch?

-- 
  .''`.  Aurelien Jarno | GPG: 1024D/F1BCDB73
 : :' :  Debian developer   | Electrical Engineer
 `. `'   [EMAIL PROTECTED] | [EMAIL PROTECTED]
   `-people.debian.org/~aurel32 | www.aurel32.net




Re: [Qemu-devel] [PATCH][PPC] mtfsf: fix FPSCR_VX and FPSCR_FEX computation

2008-01-23 Thread Aurelien Jarno
Jocelyn Mayer a écrit :
> On Mon, 2007-12-10 at 10:13 +0100, Aurelien Jarno wrote:
>> Hi all,
> 
> Hi,
> 
>> The patch below fix the computation of FPSCR_VX and FPSCR_FEX when
>> using the mtfsf instruction. As stated in the PowerPC manual the mtfsf
>> instruction can't alter those bit, and thus it should always be 
>> computed.
> 
> You're right, the values are not computed properly.
> I'll commit your fix.
> 

Any news on that?

-- 
  .''`.  Aurelien Jarno | GPG: 1024D/F1BCDB73
 : :' :  Debian developer   | Electrical Engineer
 `. `'   [EMAIL PROTECTED] | [EMAIL PROTECTED]
   `-people.debian.org/~aurel32 | www.aurel32.net




[Qemu-devel] [PATCH] hs/iommu.c add turboSPARC mask id register

2008-01-23 Thread Robert Reif

Add microSPARC II and turboSPARC mask ID register support.
Index: hw/iommu.c
===
RCS file: /sources/qemu/qemu/hw/iommu.c,v
retrieving revision 1.25
diff -p -u -r1.25 iommu.c
--- hw/iommu.c  1 Jan 2008 17:06:38 -   1.25
+++ hw/iommu.c  23 Jan 2008 14:06:26 -
@@ -34,7 +34,7 @@ do { printf("IOMMU: " fmt , ##args); } w
 #define DPRINTF(fmt, args...)
 #endif
 
-#define IOMMU_NREGS (3*4096/4)
+#define IOMMU_NREGS (4*4096/4)
 #define IOMMU_CTRL  (0x >> 2)
 #define IOMMU_CTRL_IMPL 0xf000 /* Implementation */
 #define IOMMU_CTRL_VERS 0x0f00 /* Version */
@@ -95,6 +95,12 @@ do { printf("IOMMU: " fmt , ##args); } w
 #define IOMMU_ARBEN_MASK0x001f
 #define IOMMU_MID   0x0008
 
+#define IOMMU_MASK_ID   (0x3018 >> 2) /* Mask ID */
+#define IOMMU_MASK_ID_MASK  0x00ff
+
+#define IOMMU_MSII_MASK 0x2600 /* microSPARC II mask number */
+#define IOMMU_TS_MASK   0x2300 /* turboSPARC mask number */
+
 /* The format of an iopte in the page tables */
 #define IOPTE_PAGE  0xff00 /* Physical page number (PA[35:12]) */
 #define IOPTE_CACHE 0x0080 /* Cached (in vme IOCACHE or
@@ -206,6 +212,9 @@ static void iommu_mem_writel(void *opaqu
 // addresses, fault cause and address stored to MMU/IOMMU
 s->regs[saddr] = (val & IOMMU_ARBEN_MASK) | IOMMU_MID;
 break;
+case IOMMU_MASK_ID:
+s->regs[saddr] |= (val & IOMMU_MASK_ID_MASK);
+break;
 default:
 s->regs[saddr] = val;
 break;
@@ -337,6 +346,7 @@ static void iommu_reset(void *opaque)
 s->regs[IOMMU_CTRL] = s->version;
 s->regs[IOMMU_ARBEN] = IOMMU_MID;
 s->regs[IOMMU_AFSR] = IOMMU_AFSR_RESV;
+s->regs[IOMMU_MASK_ID] = IOMMU_TS_MASK;
 qemu_irq_lower(s->irq);
 }