Re: FYI: WinKVM (Windows kernel-based virtual machine)

2010-04-30 Thread Manish Regmi
On Thu, Apr 29, 2010 at 7:36 AM, kazushi takahashi
 wrote:
> Hi there,
>
> I have ported Linux KVM to the Microsoft Windows XP and already succeeded in
> executing Linux guest OS which is attached in QEMU. I have named this virtual
> machine WinKVM.
>
> I introduced a daring and original means to develop WinKVM. More specifically,
> I implemented a software abstraction layer that can translate from
> Linux API into
> WinKVM Native API on Microsoft Windows kernel. KVM source code which is not
>  patched, is linked with my software abstraction layer when building WinKVM.
> So, I did not fix KVM itself. I only prepared the software abstraction
> layer to build
>  WinKVM.
>
> This is because KVM development speed is so fast. If I simply read KVM source
> code and only regenerate the Windows driver that is similar to be KVM, I can
> not follow to the KVM developers. It is hard to reprogram KVM when it
> has update.
>
> So, I have decided to implement the abstraction layer that emulate Linux 
> kernel
> on Microsoft Windows.
>
> I have not yet prepared the amenities which are related to WinKVM such as
> document and website and so on. But I have github repository
> http://github.com/ddk50/winkvm/
>
> I would appreciate your feedback.
>
> Regards,
> Kazushi Takahashi.
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

awesome. i would suggest to provide a binary installer somewhere. most
windows user would love that.  look for sourceforge or similar for
hosting.
does it compile with mingw?

---
regards
Manish Regmi

http://manish-cs.blogspot.com
http://ext2read.sf.net
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: using ftrace with kvm

2010-04-22 Thread Manish Regmi
On Thu, Apr 22, 2010 at 3:53 PM, David S. Ahern  wrote:
I have a VM that is spinning (both vcpus at 100%). As I recall kvm_stat
has been deprecated in favor or ftrace. Is there a wiki page or document
that gives suggestions on this?

David

Documentation/trace/* is the place to see.

but for me function and function_graph give too much data even if i
limit it to 1 function. so i use trace points. i simply enable the
tracepoints i am interested in and read trace_pipe.

cat available_events
echo kvm:* > set_event
cat trace_pipe > ~/mydump.txt (or whatever you want to do)

---
regards
Manish Regmi

http://manish-cs.blogspot.com
http://ext2read.sf.net
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/1 V2 RESEND] Add new VM Exit codes

2010-04-19 Thread Manish Regmi
sorry the last one was word wrapped. now i fixed it.

hi, this patch,
 * adds two more EXIT_REASONS 33 and 34 in vmx.h
 * also adds them to exit reason strings.
Signed-off-by: Manish Regmi 

diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index fb9a080..9bf84db 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -251,6 +251,8 @@ enum vmcs_field {
 #define EXIT_REASON_IO_INSTRUCTION  30
 #define EXIT_REASON_MSR_READ31
 #define EXIT_REASON_MSR_WRITE   32
+#define EXIT_REASON_INVALID_GUEST_STATE 33
+#define EXIT_REASON_MSR_LOADING 34
 #define EXIT_REASON_MWAIT_INSTRUCTION   36
 #define EXIT_REASON_MONITOR_INSTRUCTION 39
 #define EXIT_REASON_PAUSE_INSTRUCTION   40
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 0b896ac..a5c53ad 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4061,6 +4061,8 @@ static const struct trace_print_flags 
vmx_exit_reasons_str[] = {
_ER(IO_INSTRUCTION),
_ER(MSR_READ),
_ER(MSR_WRITE),
+_ER(INVALID_GUEST_STATE),
+_ER(MSR_LOADING),
_ER(MWAIT_INSTRUCTION),
_ER(MONITOR_INSTRUCTION),
_ER(PAUSE_INSTRUCTION),

regards,
Manish Regmi
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1 V2] clear leftmost bit when exit failure is vm entry type

2010-04-19 Thread Manish Regmi
hi,
 When the vm exit reason is VM Entry failures it has leftmost bit set.
 This patch
 - clears the leftmost bit when copying to vmx->exit_reason. This will make the 
checks like 
   if ((vmx->exit_reason == EXIT_REASON_MCE_DURING_VMENTRY) valid in 
vmx_complete_interrupts.

Signed-off-by: Manish Regmi 


diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 0b896ac..e0ca917 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3642,7 +3642,7 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
 
exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
 
-   vmx->exit_reason = vmcs_read32(VM_EXIT_REASON);
+   vmx->exit_reason = vmcs_read32(VM_EXIT_REASON) & 
~VMX_EXIT_REASONS_FAILED_VMENTRY;
 
/* Handle machine checks before interrupts are enabled */
if ((vmx->exit_reason == EXIT_REASON_MCE_DURING_VMENTRY)

regards
Manish Regmi
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/1 V2] Add new VM Exit codes

2010-04-19 Thread Manish Regmi

hi, this patch,
* adds two more EXIT_REASONS 33 and 34 in vmx.h
* also adds them to exit reason strings.

Signed-off-by: Manish Regmi 

diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index fb9a080..9bf84db 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -251,6 +251,8 @@ enum vmcs_field {
#define EXIT_REASON_IO_INSTRUCTION  30
#define EXIT_REASON_MSR_READ31
#define EXIT_REASON_MSR_WRITE   32
+#define EXIT_REASON_INVALID_GUEST_STATE 33
+#define EXIT_REASON_MSR_LOADING 34
#define EXIT_REASON_MWAIT_INSTRUCTION   36
#define EXIT_REASON_MONITOR_INSTRUCTION 39
#define EXIT_REASON_PAUSE_INSTRUCTION   40
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 0b896ac..a5c53ad 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4061,6 +4061,8 @@ static const struct trace_print_flags 
vmx_exit_reasons_str[] = {

_ER(IO_INSTRUCTION),
_ER(MSR_READ),
_ER(MSR_WRITE),
+_ER(INVALID_GUEST_STATE),
+_ER(MSR_LOADING),
_ER(MWAIT_INSTRUCTION),
_ER(MONITOR_INSTRUCTION),
_ER(PAUSE_INSTRUCTION),


regards,
Manish Regmi

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/1] trace all instructions whose emulation failed

2010-04-19 Thread Manish Regmi
On Mon, Apr 19, 2010 at 4:20 AM, Avi Kivity  wrote:
>>        }
>>
>>
>
> It's better not to trace #UD triggered emulations, since we except these to
> fail, for example if the guest executes the UD2 instruction.
>

ya. that sounds more logical. Thanks for explaining.
-------
regards
Manish Regmi

http://manish-cs.blogspot.com
http://ext2read.sf.net
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] correctly handle VM Entry Exit reasons and also show them in trace.

2010-04-17 Thread Manish Regmi
Hi,
 When the vm exit reason is VM Entry failures it has leftmost bit set.
This patch
 - clears the leftmost bit when copying to vmx->exit_reason. This will
make the checks like if ((vmx->exit_reason ==
EXIT_REASON_MCE_DURING_VMENTRY) valid in vmx_complete_interrupts.
 - adds two more EXIT_REASONS 33 and 34 in vmx.h
 - also adds them to exit reason strings.

Please let me know if there is anything missing or wrong. Thank you.

Signed-off-by: Manish Regmi 

diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index fb9a080..9bf84db 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -251,6 +251,8 @@ enum vmcs_field {
 #define EXIT_REASON_IO_INSTRUCTION  30
 #define EXIT_REASON_MSR_READ31
 #define EXIT_REASON_MSR_WRITE   32
+#define EXIT_REASON_INVALID_GUEST_STATE 33
+#define EXIT_REASON_MSR_LOADING 34
 #define EXIT_REASON_MWAIT_INSTRUCTION   36
 #define EXIT_REASON_MONITOR_INSTRUCTION 39
 #define EXIT_REASON_PAUSE_INSTRUCTION   40
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 7e2f8d5..e93be6f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3641,7 +3641,7 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)

exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);

-   vmx->exit_reason = vmcs_read32(VM_EXIT_REASON);
+   vmx->exit_reason = vmcs_read32(VM_EXIT_REASON) &
~VMX_EXIT_REASONS_FAILED_VMENTRY;

/* Handle machine checks before interrupts are enabled */
if ((vmx->exit_reason == EXIT_REASON_MCE_DURING_VMENTRY)
@@ -4057,6 +4057,8 @@ static const struct trace_print_flags
vmx_exit_reasons_str[] = {
_ER(IO_INSTRUCTION),
_ER(MSR_READ),
_ER(MSR_WRITE),
+   _ER(INVALID_GUEST_STATE),
+   _ER(MSR_LOADING),
_ER(MWAIT_INSTRUCTION),
_ER(MONITOR_INSTRUCTION),
_ER(PAUSE_INSTRUCTION),

-------
regards
Manish Regmi

http://manish-cs.blogspot.com
http://ext2read.sf.net
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/1] trace all instructions whose emulation failed

2010-04-17 Thread Manish Regmi
Hi,
  The following patch makes sure all code path of failed emulation
runs trace_kvm_emulate_insn_failed().
Please let me know if there is anything missing or wrong.
Thank you.

Signed-off-by: Manish Regmi 

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b6e7535..fd1e875 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3784,36 +3784,35 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
c = &vcpu->arch.emulate_ctxt.decode;
if (emulation_type & EMULTYPE_TRAP_UD) {
if (!c->twobyte)
-   return EMULATE_FAIL;
+   goto emulate_failed;
switch (c->b) {
case 0x01: /* VMMCALL */
if (c->modrm_mod != 3 || c->modrm_rm != 1)
-   return EMULATE_FAIL;
+   goto emulate_failed;
break;
case 0x34: /* sysenter */
case 0x35: /* sysexit */
if (c->modrm_mod != 0 || c->modrm_rm != 0)
-   return EMULATE_FAIL;
+   goto emulate_failed;
break;
case 0x05: /* syscall */
if (c->modrm_mod != 0 || c->modrm_rm != 0)
-   return EMULATE_FAIL;
+   goto emulate_failed;;
break;
default:
-   return EMULATE_FAIL;
+   goto emulate_failed;
}

if (!(c->modrm_reg == 0 || c->modrm_reg == 3))
-   return EMULATE_FAIL;
+   goto emulate_failed;
}

++vcpu->stat.insn_emulation;
if (r)  {
++vcpu->stat.insn_emulation_fail;
-   trace_kvm_emulate_insn_failed(vcpu);
if (kvm_mmu_unprotect_page_virt(vcpu, cr2))
return EMULATE_DONE;
-   return EMULATE_FAIL;
+   goto emulate_failed;
}
}

@@ -3848,9 +3847,8 @@ restart:
goto done;
if (!vcpu->mmio_needed) {
++vcpu->stat.insn_emulation_fail;
-   trace_kvm_emulate_insn_failed(vcpu);
kvm_report_emulation_failure(vcpu, "mmio");
-   return EMULATE_FAIL;
+   goto emulate_failed;
}
return EMULATE_DO_MMIO;
}
@@ -3868,6 +3866,10 @@ done:
goto restart;

return EMULATE_DONE;
+
+emulate_failed:
+   trace_kvm_emulate_insn_failed(vcpu);
+   return EMULATE_FAIL;
 }
 EXPORT_SYMBOL_GPL(emulate_instruction);


-------
regards
Manish Regmi

http://manish-cs.blogspot.com
http://ext2read.sf.net
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


kvmtrace and debugging kvm

2010-04-13 Thread Manish Regmi
hi,
  I am trying to use kvmtrace but it looks like its no longer used. in
kvm_main.c it is returning -EOPNOTSUP.
kvmtrace -V -D test -o mykvmtest
does not seem to do anything.

is it no longer used? is there any better way of debugging kvm?
Thank you.

---
regards
Manish Regmi

http://manish-cs.blogspot.com
http://ext2read.sf.net
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html