KQEMU on Win32 (+patch)
Hi,
as there were recently few questions about KQEMU I decided to dedicate few minutes at answering them and to post a few comments.
Quoted 2 lines
I'm trying to find out why qvm86 crashes the host (instant reboot when right clicking on some icons on the guest desktop). So i thought if it is possible to use some code from
kqemu-win32.cto updateqvm86-win32.c
No, I wrote both of the files and I can honestly tell you that copying between them will not help. There is one known case where QVM86 on WinNT platforms crashes the host machine and that's when NOEXECUTE support is enabled (see boot.ini). The method QVM86 uses for executing the code involves copying executable code into an allocated page which unfortunately has the NX bit set. I have an experimental fix for this, but I need someone with adequate environment (AMD64 and Win XP SP2+) to test it... Of course host crash can be caused by other bug.
(Also note that this may apply to KQEMU too though I have no proof.)
Quoted 4 lines
The changelog mentions that the KQEMU accelerator is now available as a preliminary executable for Windows. I've not been able to find a link to that version anywhere. Should I pull down the sources and compile on my Linux machine, or is there a pre-compiled version about?
You can compile it yourself on either Windows machine with MinGW or on linux machine with MinGW cross-compiler. I'm temporary hosting a set of QEMU / KQEMU 0.7.1 for Windows binaries here: http://www.volny.cz/xnavara/qemu-0.7.1.zip. If anyone can offer me hosting for these binaries I would be glad.
As a final note (especially for Fabrice), attached are patches for KQEMU for easier driver installation (quite not there yet, but a bit closer) and implementation of kqemu_schedule (as requested). I'm planing to port this to QVM86 shortly.
Best regards,
Filip
Index: exec-all.h
===================================================================
RCS file: /cvsroot/qemu/qemu/exec-all.h,v
retrieving revision 1.34
exec-all.h +1 -0
@@ -607,6 +607,7 @@ int kqemu_init(CPUState *env);int kqemu_cpu_exec (CPUState *env);void kqemu_flush_page (CPUState *env,target_ulong addr);void kqemu_flush (CPUState *env,int global); +void kqemu_cpu_interrupt (CPUState *env);static inline int kqemu_is_ok (CPUState *env) {
Index: kqemu.c
===================================================================
RCS file: /cvsroot/qemu/qemu/kqemu.c,v
retrieving revision 1.4
kqemu.c +17 -5
@@ -456,11 +456,14 @@ int kqemu_cpu_exec(CPUState *env) }#ifdef _WIN32 -DeviceIoControl (kqemu_fd,KQEMU_EXEC , - kenv,sizeof (struct kqemu_cpu_state ), - kenv,sizeof (struct kqemu_cpu_state ), - &temp,NULL ); - ret = kenv->retval; +if (DeviceIoControl (kqemu_fd,KQEMU_EXEC , + kenv,sizeof (struct kqemu_cpu_state ), + kenv,sizeof (struct kqemu_cpu_state ), + &temp,NULL )) { + ret = kenv->retval; + }else { + ret =-1 ; + }#else #if KQEMU_VERSION >=0x010100 ioctl (kqemu_fd,KQEMU_EXEC , kenv);
@@ -544,6 +547,15 @@ int kqemu_cpu_exec(CPUState *env) exit(1); }return 0 ; +} + +void kqemu_cpu_interrupt (CPUState *env) +{ +#if defined(_WIN32) &&KQEMU_VERSION >=0x010101 +/* cancelling the I/O request causes KQEMU to finish executing the +current block and successfully returning. */ +CancelIo (kqemu_fd); +#endif }#endif
Index: vl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.c,v
retrieving revision 1.133
vl.c +3 -0
@@ -875,6 +875,9 @@ static void host_alarm_handler(int host_ qemu_get_clock(rt_clock))) {/* stop the cpu because a timer occured */ cpu_interrupt (global_env,CPU_INTERRUPT_EXIT ); +#ifdef USE_KQEMU +kqemu_cpu_interrupt (global_env); +#endif } }
kqemu-doc.html +1 -10
@@ -173,16 +173,7 @@ the option <CODE>major=N</CODE> to set a <H2><A NAME="SEC5" HREF="kqemu-doc.html#TOC5">2.3 QEMU Accelerator Installation for Windows</A></H2> <P> -Copy the kqemu driver <TT>`kqemu.sys'</TT> to -<TT>`c:\winnt\system32\drivers'</TT>. Then do: - -<PRE> -regedit kqemu.reg -</PRE> - -<P> -Now kqemu is installed and you must restart your system. - +Right click on <TT>`kqemu.inf'</TT> in Explorer and choose Install. <P> In order to start kqemu, you must do:
kqemu-doc.texi +1 -7
@@ -112,13 +112,7 @@ the option @code{major=N} to set an alte @section QEMU Accelerator Installation for Windows -Copy the kqemu driver @file{kqemu.sys} to -@file{c:\winnt\system32\drivers}. Then do: -@example -regedit kqemu.reg -@end example - -Now kqemu is installed and you must restart your system. +Right click on @file{kqemu.inf} in Explorer and choose Install. In order to start kqemu, you must do: @example
kqemu-win32.c +25 -8
@@ -36,6 +36,14 @@ typedef unsigned long long uint64_t;/* XXX: make it dynamic according to available RAM */ #define MAX_LOCKED_PAGES (16386 / 4) +struct kqemu_instance { +struct kqemu_state *state; +PIRP current_irp; +}; + +FAST_MUTEX instance_lock; +struct kqemu_instance *active_instance; +/* lock the page at virtual address 'user_addr' and return its page index. Return -1 if error */ struct kqemu_user_page *CDECL kqemu_lock_user_page(unsigned long *ppage_index,
@@ -150,19 +158,19 @@ void CDECL kqemu_io_unmap(void *ptr, unsexecution) */ int CDECL kqemu_schedule(void) { -/* XXX: do it */ -return TRUE; +return active_instance->current_irp->Cancel; } void CDECL kqemu_log(const char *fmt, ...) { -/* XXX: format parameters */ -DbgPrint ("%s" , fmt); -} +char log_buf[1024 ]; +va_list ap; -struct kqemu_instance { -struct kqemu_state *state; -}; +va_start (ap, fmt); +_vsnprintf (log_buf,sizeof (log_buf), fmt, ap); +DbgPrint ("kqemu: %s" , log_buf); +va_end (ap); +} NTSTATUS STDCALLKQemuCreate (PDEVICE_OBJECT DeviceObject,PIRP Irp)
@@ -256,12 +264,19 @@ KQemuDeviceControl(PDEVICE_OBJECT Devicebreak ; } +ExAcquireFastMutex (&instance_lock); + active_instance = State; + State->current_irp = Irp; + ctx =kqemu_get_cpu_state (State->state);RtlCopyMemory (ctx, Irp->AssociatedIrp.SystemBuffer,sizeof (*ctx)); ret =kqemu_exec (State->state);RtlCopyMemory (Irp->AssociatedIrp.SystemBuffer, ctx,sizeof (*ctx)); + +ExReleaseFastMutex (&instance_lock); + Irp->IoStatus.Information =sizeof (*ctx); Status =STATUS_SUCCESS ; }
@@ -311,6 +326,8 @@ DriverEntry(PDRIVER_OBJECT DriverObject, (KQEMU_VERSION) & 0xff);MmLockPagableCodeSection (DriverEntry); + +ExInitializeFastMutex (&instance_lock); DriverObject->MajorFunction[IRP_MJ_CREATE ] = KQemuCreate; DriverObject->MajorFunction[IRP_MJ_CLOSE ] = KQemuClose;
kqemu.h +1 -1
@@ -1,7 +1,7 @@ #ifndef KQEMU_H #define KQEMU_H -#define KQEMU_VERSION 0x010100 +#define KQEMU_VERSION 0x010101 struct kqemu_segment_cache { uint32_t selector;
kqemu.inf +64 -0
64 lines not on this page · raw message
kqemu.reg deleted +0 -7
@@ -1,7 +0,0 @@ -REGEDIT4 - -[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\kqemu] -"Type"=dword:00000001 -"Start"=dword:00000003 -"ErrorControl"=dword:00000001 -"DisplayName"="kqemu"
I've updated my QEMU download section: http://qemu.dad-answers.com/download/
Your binaries are there now (under the win32 directory)
Thanks,
Hetz
Quoted 49 lines · Filip Navara
Hi,
as there were recently few questions about KQEMU I decided to dedicate few minutes at answering them and to post a few comments.
Quoted 1 line
I'm trying to find out why qvm86 crashes the host (instant reboot
when right clicking on some icons on the guest desktop).
Quoted 1 line
So i thought if it is possible to use some code from
kqemu-win32.ctoupdate
qvm86-win32.cNo, I wrote both of the files and I can honestly tell you that copying between them will not help. There is one known case where QVM86 on WinNT platforms crashes the host machine and that's when NOEXECUTE support is enabled (see boot.ini). The method QVM86 uses for executing the code involves copying executable code into an allocated page which unfortunately has the NX bit set. I have an experimental fix for this, but I need someone with adequate environment (AMD64 and Win XP SP2+) to test it... Of course host crash can be caused by other bug.
(Also note that this may apply to KQEMU too though I have no proof.)
Quoted 4 lines
The changelog mentions that the KQEMU accelerator is now available as a preliminary executable for Windows. I've not been able to find a link to that version anywhere. Should I pull down the sources and compile on my Linux machine, or is there a pre-compiled version about?
You can compile it yourself on either Windows machine with MinGW or on linux machine with MinGW cross-compiler. I'm temporary hosting a set of QEMU / KQEMU 0.7.1 for Windows binaries here:
http://www.volny.cz/xnavara/qemu-0.7.1.zip. If anyone can offer me hosting for these binaries I would be glad.As a final note (especially for Fabrice), attached are patches for KQEMU for easier driver installation (quite not there yet, but a bit closer) and implementation of
kqemu_schedule(as requested). I'm planing to port this to QVM86 shortly.Best regards,
Filip_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Quoted 7 lines · Filip Navara
Quoted 1 line
I'm trying to find out why qvm86 crashes the host (instant reboot
when right clicking on some icons on the guest desktop).
Quoted 1 line
So i thought if it is possible to use some code from
kqemu-win32.ctoupdate
qvm86-win32.cNo, I wrote both of the files and I can honestly tell you that copying between them will not help. There is one known case where QVM86 on WinNT platforms crashes the host machine and that's when NOEXECUTE support is enabled (see boot.ini). The method QVM86 uses for executing the code involves copying executable code into an allocated page which unfortunately has the NX bit set. I have an experimental fix for this, but I need someone with adequate environment (AMD64 and Win XP SP2+) to test it... Of course host crash can be caused by other bug.
I knew you wrote them both (who else could?). I was (wrongly) thinking that the qvm86 version is older than kqemu but apparently they work differently (thanks for the clarification).
As for the NOEXECUTE, i'm testing kqemu and qvm86 on a Athlon XP (regular 32bit, without NX). So the instant reboots must be from something else.
Quoted 1 line
You can compile it yourself on either Windows machine with MinGW or on linux machine with MinGW cross-compiler.
I tried to compile kqemu with MinGW without luck (although i didn't push it much). The error was:
kqemu-win32.o(.text+0x217):kqemu-win32.c: undefined reference to `_imp__MmMapIoSpace@16'
Probably it is that i don't have the windows driver development kit.
I'm temporary hosting a set of
Quoted 1 line
QEMU / KQEMU 0.7.1 for Windows binaries here: http://www.volny.cz/xnavara/qemu-0.7.1.zip.
Do these binaries include your latest patches?
teris.
ps I cannot imagine how a man can know that much about the windows internals and at the same time be comfortable working with linux device drivers stuff.
Quoted 9 lines · Elefterios Stamatogiannakis
[snip]
Quoted 1 line
You can compile it yourself on either Windows machine with MinGW or on linux machine with MinGW cross-compiler.
I tried to compile kqemu with MinGW without luck (although i didn't push it much). The error was:
kqemu-win32.o(.text+0x217):kqemu-win32.c: undefined reference to `_imp__MmMapIoSpace@16'
Probably it is that i don't have the windows driver development kit.
This is common problem. IIRC you need to update the MinGW W32API package.
Quoted 6 lines
I'm temporary hosting a set of
Quoted 1 line
QEMU / KQEMU 0.7.1 for Windows binaries here: http://www.volny.cz/xnavara/qemu-0.7.1.zip.
Do these binaries include your latest patches?
Yes
Best regards,
Filip
QEMU+KQEMU 0.7.1 on windows is still too slow
when run linux guest system.menu is delay
inside the qemu monitor (CTRL-ALT-2), type "info kqemu". Just to confirm.
If you get "kqemu is enabled", report exactly which linux guest you're using. Did you do your own qemu compilation ?
if not, you surely missed applying the regedit file, reboot the machine and do a "net start kqemu".
Side question: is there a way to start this net service automatically ?
Christian
Quoted 9 lines · 姚春林
QEMU+KQEMU 0.7.1 on windows is still too slow
when run linux guest system.menu is delay
_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Quoted 10 lines · Christian MICHON
inside the qemu monitor (CTRL-ALT-2), type "info kqemu". Just to confirm.
If you get "kqemu is enabled", report exactly which linux guest you're using. Did you do your own qemu compilation ?
if not, you surely missed applying the regedit file, reboot the machine and do a "net start kqemu".
JFYI, I replaced the .reg file with .inf file and the restart is no longer necessary.
Quoted 4 lines
Side question: is there a way to start this net service automatically ?
Generally yes.
- With the current setup you can change the driver settings to enable loading it on Windows start by editing the "Start" values in "HKEY_LOCAL_MACHINE/Software/CurrentControlSet/Services/KQEMU" registry key and setting it to "2".
- In future I plan to add code for auto-loading the KQEMU driver to QEMU if Fabrice agrees.
- Filip
Host system Tinkpad R40e P4 2G 768M WINXP pro
qemu 0.7.1 mem 256
2005/7/28, Christian MICHON <[email protected]>:
Quoted 3 lines
inside the qemu monitor (CTRL-ALT-2), type "info kqemu". Just to confirm.
kqemu is enadled
If you get "kqemu is enabled", report exactly which linux
Quoted 1 line
guest you're using. Did you do your own qemu compilation ?
debian + gnome 2.1
gnome is slow . and vmware with 256mem is more faster then qemu.
console is not feeling slow,XWindow is more slow.
if not, you surely missed applying the regedit file, reboot the
Quoted 24 lines
machine and do a "net start kqemu".
Side question: is there a way to start this net service automatically ?
Christian
Quoted 9 lines · 姚春林
QEMU+KQEMU 0.7.1 on windows is still too slow
when run linux guest system.menu is delay
_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Signature · 8 lines
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ /_/ 中国 ・ 江蘇省 ・ 南通 /_/ /_/ 姚春林 /_/ /_/ E-mail:[email protected] <http://gmail.com> /_/ WEB : /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
found out why :)
On 7/28/05, 姚春林 wrote:
(...)
Quoted 2 lines
debian + gnome 2.1
gnome is slow . and vmware with 256mem is more faster then qemu.
answer is: gnome usage. Bad idea, which ever is your emulator. Try to go for lighter window manager environment, like fluxbox.
Try also to boot in framebuffer mode, in 800x600x16bpp. I noticed this mode is quite fast :)
I think there are some patches to try to improve the cirrus emulated. But I haven't seen any updated for a long time.
Christian
Cirrus Emulation (was: [Qemu-devel] KQEMU on Win32 (+patch))
Hmm,
Anyone has patches for Cirrus Logic emulation that hasn't been applied yet?
If so, could someone send them over please?
Thanks,
Hetz
Quoted 24 lines · Christian MICHON
found out why :)
On 7/28/05, 姚春林 wrote:
(...)Quoted 2 lines
debian + gnome 2.1
gnome is slow . and vmware with 256mem is more faster then qemu.answer is: gnome usage. Bad idea, which ever is your emulator. Try to go for lighter window manager environment, like fluxbox.
Try also to boot in framebuffer mode, in 800x600x16bpp. I noticed this mode is quite fast :)
I think there are some patches to try to improve the cirrus emulated. But I haven't seen any updated for a long time.
Christian
_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Re: Cirrus Emulation (was: [Qemu-devel] KQEMU on Win32 (+patch))
http://cyberkinetica.homeunix.net/qemu/cirrus_vga.patch.gz
I found back the patch I mentionned. It's not in v0.7.1, but I do not know its effects yet on cirrus speed.
It's tagged on Antony's page as:
"Attempt to speed up Cirrus VGA"
Christian
Quoted 8 lines · Hetz Ben Hamo
Hmm,
Anyone has patches for Cirrus Logic emulation that hasn't been applied yet?
If so, could someone send them over please?
Thanks,
Hetz
Re: Cirrus Emulation (was: [Qemu-devel] KQEMU on Win32 (+patch))
Quoted 4 lines · Christian MICHON
http://cyberkinetica.homeunix.net/qemu/cirrus_vga.patch.gz
It's tagged on Antony's page as:
"Attempt to speed up Cirrus VGA"
I tried it yesterday with proper graphical benchmarks (win95 guest). Some rendering is wrong on fonts (especially letter W uppercase) and there's no speed improvement actually. :(
Any other patch or alternative card under dev ?
Christian
If you are running Linux under Windows, I highly recommend using coLinux. It is more of a pain to initially configure, but once it is the code runs just as fast as with a native Linux boot. Maybe someday, someone will merge the front ends to these two entirely different programs...
If anyone knows some good Linux benchmark programs it would be interesting to run comparisons on the same hardware of the two different methods of vitalization.
Don't get me wrong, I am a strong advocate of QEMU. But only for environments where there isn't a more direct route to host another OS.
So I do use QEMU to host other Windows operating systems, but I would
only use it for Linux system when coLinux is unusable.
Bill
Quoted 24 lines · Christian MICHON
found out why :)
On 7/28/05, 姚春林 wrote:
(...)Quoted 2 lines
debian + gnome 2.1
gnome is slow . and vmware with 256mem is more faster then qemu.answer is: gnome usage. Bad idea, which ever is your emulator. Try to go for lighter window manager environment, like fluxbox.
Try also to boot in framebuffer mode, in 800x600x16bpp. I noticed this mode is quite fast :)
I think there are some patches to try to improve the cirrus emulated. But I haven't seen any updated for a long time.
Christian
_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Hi,
Quoted 2 lines · Doctor Bill
If you are running Linux under Windows, I highly recommend using coLinux.
AFAIK coLinux is
- only for WinNT and "better"
- not easily modified, because it relies on proprietary development components.
Ciao,
Dscho
Quoted 3 lines · Johannes Schindelin
Quoted 2 lines · Doctor Bill
If you are running Linux under Windows, I highly recommend using coLinux.
It also requires a modified kernel, as coLinux is a different kind off "CPU."
Signature · 3 lines
Joshua Kugler CDE System Administrator http://distance.uaf.edu/