[PATCH] KVM: VMX: Conditionally request interrupt window after injecting irq

2008-11-23 Thread Avi Kivity
From: Avi Kivity <[EMAIL PROTECTED]>

If we're injecting an interrupt, and another one is pending, request
an interrupt window notification so we don't have excess latency on the
second interrupt.

This shouldn't happen in practice since an EOI will be issued, giving a second
chance to request an interrupt window, but...

Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f5958a7..7ea4855 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3304,6 +3304,8 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu)
if (vcpu->arch.interrupt.pending) {
vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
kvm_timer_intr_post(vcpu, vcpu->arch.interrupt.nr);
+   if (kvm_cpu_has_interrupt(vcpu))
+   enable_irq_window(vcpu);
}
 }
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Merge branch 'qemu-cvs'

2008-11-23 Thread Avi Kivity
From: Avi Kivity <[EMAIL PROTECTED]>

Conflicts:
qemu/block-raw-posix.c
qemu/configure
qemu/cpu-defs.h
qemu/cpu-exec.c
qemu/exec.c
qemu/gdbstub.c
qemu/loader.c
qemu/osdep.c
qemu/sysemu.h
qemu/target-i386/helper.c
qemu/target-ppc/cpu.h
qemu/target-ppc/helper.c
qemu/usb-linux.c

Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM: ia64: Clean up vmm_ivt.S using tab to indent every line

2008-11-23 Thread Avi Kivity
From: Xiantao Zhang <[EMAIL PROTECTED]>

Using tab for indentation for vmm_ivt.S.

Signed-off-by: Xiantao Zhang <[EMAIL PROTECTED]>
Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/arch/ia64/kvm/vmm_ivt.S b/arch/ia64/kvm/vmm_ivt.S
index 50b4646..3ef1a01 100644
--- a/arch/ia64/kvm/vmm_ivt.S
+++ b/arch/ia64/kvm/vmm_ivt.S
@@ -1,5 +1,5 @@
 /*
- * /ia64/kvm_ivt.S
+ * arch/ia64/kvm/vmm_ivt.S
  *
  * Copyright (C) 1998-2001, 2003 Hewlett-Packard Co
  *  Stephane Eranian <[EMAIL PROTECTED]>
@@ -71,37 +71,37 @@
 #endif
 
 #define KVM_FAULT(n)\
-kvm_fault_##n:;  \
-mov r19=n;;  \
-br.sptk.many kvm_vmm_panic; \
-;;  \
+   kvm_fault_##n:;  \
+   mov r19=n;;  \
+   br.sptk.many kvm_vmm_panic; \
+   ;;  \
 
 #define KVM_REFLECT(n)\
-mov r31=pr;   \
-mov r19=n;   /* prepare to save predicates */ \
-mov r29=cr.ipsr;  \
-;;  \
-tbit.z p6,p7=r29,IA64_PSR_VM_BIT;   \
-(p7)br.sptk.many kvm_dispatch_reflection;\
-br.sptk.many kvm_vmm_panic;  \
+   mov r31=pr;   \
+   mov r19=n;   /* prepare to save predicates */ \
+   mov r29=cr.ipsr;  \
+   ;;  \
+   tbit.z p6,p7=r29,IA64_PSR_VM_BIT;   \
+(p7)   br.sptk.many kvm_dispatch_reflection;\
+   br.sptk.many kvm_vmm_panic;  \
 
 GLOBAL_ENTRY(kvm_vmm_panic)
-KVM_SAVE_MIN_WITH_COVER_R19
-alloc r14=ar.pfs,0,0,1,0
-mov out0=r15
-adds r3=8,r2// set up second base pointer
-;;
-ssm psr.ic
-;;
-srlz.i  // guarantee that interruption collection is on
-;;
-//(p15) ssm psr.i   // restore psr.i
-addl [EMAIL PROTECTED](ia64_leave_hypervisor),gp
-;;
-KVM_SAVE_REST
-mov rp=r14
-;;
-br.call.sptk.many b6=vmm_panic_handler;
+   KVM_SAVE_MIN_WITH_COVER_R19
+   alloc r14=ar.pfs,0,0,1,0
+   mov out0=r15
+   adds r3=8,r2// set up second base pointer
+   ;;
+   ssm psr.ic
+   ;;
+   srlz.i// guarantee that interruption collection is on
+   ;;
+   //(p15) ssm psr.i   // restore psr.i
+   addl [EMAIL PROTECTED](ia64_leave_hypervisor),gp
+   ;;
+   KVM_SAVE_REST
+   mov rp=r14
+   ;;
+   br.call.sptk.many b6=vmm_panic_handler;
 END(kvm_vmm_panic)
 
 .section .text.ivt,"ax"
@@ -112,308 +112,307 @@ kvm_ia64_ivt:
 ///
 // 0x Entry 0 (size 64 bundles) VHPT Translation (8,20,47)
 ENTRY(kvm_vhpt_miss)
-KVM_FAULT(0)
+   KVM_FAULT(0)
 END(kvm_vhpt_miss)
 
-
 .org kvm_ia64_ivt+0x400
 
 // 0x0400 Entry 1 (size 64 bundles) ITLB (21)
 ENTRY(kvm_itlb_miss)
-mov r31 = pr
-mov r29=cr.ipsr;
-;;
-tbit.z p6,p7=r29,IA64_PSR_VM_BIT;
-(p6) br.sptk kvm_alt_itlb_miss
-mov r19 = 1
-br.sptk kvm_itlb_miss_dispatch
-KVM_FAULT(1);
+   mov r31 = pr
+   mov r29=cr.ipsr;
+   ;;
+   tbit.z p6,p7=r29,IA64_PSR_VM_BIT;
+(p6)   br.sptk kvm_alt_itlb_miss
+   mov r19 = 1
+   br.sptk kvm_itlb_miss_dispatch
+   KVM_FAULT(1);
 END(kvm_itlb_miss)
 
 .org kvm_ia64_ivt+0x0800
 //
 // 0x0800 Entry 2 (size 64 bundles) DTLB (9,48)
 ENTRY(kvm_dtlb_miss)
-mov r31 = pr
-mov r29=cr.ipsr;
-;;
-tbit.z p6,p7=r29,IA64_PSR_VM_BIT;
-(p6)br.sptk kvm_alt_dtlb_miss
-br.sptk kvm_dtlb_miss_dispatch
+   mov r31 = pr
+   mov r29=cr.ipsr;
+   ;;
+   tbit.z p6,p7=r29,IA64_PSR_VM_BIT;
+(p6)   br.sptk kvm_alt_dtlb_miss
+   br.sptk kvm_dtlb_miss_dispatch
 END(kvm_dtlb_miss)
 
  .org kvm_ia64_ivt+0x0c00
 
 // 0x0c00 Entry 3 (size 64 bundles) Alt ITLB (19)
 ENTRY(kvm_alt_itlb_miss)
-mov r16=cr.ifa// get address that caused the TLB miss
-;;
-movl r17=PAGE_KERNEL
-mov r24=cr.ipsr
-movl r19=(((1 << IA64_MAX_PHYS_BITS) - 1) & ~0xfff)
-;;
-and r19=r19,r16 // clear ed, reserved bits, and PTE control bits
-;;
-or r19=r17,r19  // insert PTE control bits into r19
-;;
-movl r20=IA64_GRANULE_SHIFT<<2
-;;
-mov cr.itir=r20
-;;
-itc.i r19  // insert the TLB entry
-mov pr=r31,-1
-rfi
+   mov r16=cr.ifa// get address that caused the TLB miss
+   ;;
+   movl r17=PAGE_KERNEL
+   mov r24=cr.ipsr
+   movl r19=(((1 << IA64_MAX_PHYS_BITS) - 1) & ~0xfff)
+   ;;
+   and r19=r19,r16 // clear ed, reserved bits, and PTE control bits
+   ;;
+   or r19=r17,r19  // insert PTE control bits into r19
+   ;;
+   movl r20=IA64_GRANULE_SHIFT<<2
+   ;;
+   mov cr.itir=r20
+   ;;
+   itc.i r19   // insert the TLB entry
+

[PATCH] KVM: ia64: Fix: Use correct calling convention for PAL_VPS_RESUME_HANDLER

2008-11-23 Thread Avi Kivity
From: Xiantao Zhang <[EMAIL PROTECTED]>

PAL_VPS_RESUME_HANDLER should use r26 to hold vac fields according to SDM.

Signed-off-by: Xiantao Zhang <[EMAIL PROTECTED]>
Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/arch/ia64/kvm/optvfault.S b/arch/ia64/kvm/optvfault.S
index 634abad..32254ce 100644
--- a/arch/ia64/kvm/optvfault.S
+++ b/arch/ia64/kvm/optvfault.S
@@ -107,10 +107,10 @@ END(kvm_vps_resume_normal)
 GLOBAL_ENTRY(kvm_vps_resume_handler)
movl r30 = PAL_VPS_RESUME_HANDLER
;;
-   ld8 r27=[r25]
+   ld8 r26=[r25]
shr r17=r17,IA64_ISR_IR_BIT
;;
-   dep r27=r17,r27,63,1   // bit 63 of r27 indicate whether enable CFLE
+   dep r26=r17,r26,63,1   // bit 63 of r26 indicate whether enable CFLE
mov pr=r23,-2
br.sptk.many kvm_vps_entry
 END(kvm_vps_resume_handler)
@@ -894,12 +894,15 @@ ENTRY(kvm_resume_to_guest)
;;
ld8 r19=[r19]
mov b0=r29
-   cmp.ne p6,p7 = r0,r0
+   mov r27=cr.isr
;;
-   tbit.z p6,p7 = r19,IA64_PSR_IC_BIT  // p1=vpsr.ic
+   tbit.z p6,p7 = r19,IA64_PSR_IC_BIT  // p7=vpsr.ic
+   shr r27=r27,IA64_ISR_IR_BIT
;;
(p6) ld8 r26=[r25]
(p7) mov b0=r28
+   ;;
+   (p6) dep r26=r27,r26,63,1
mov pr=r31,-2
br.sptk.many b0 // call pal service
;;
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM: ia64: Add some debug points to provide crash infomation

2008-11-23 Thread Avi Kivity
From: Xiantao Zhang <[EMAIL PROTECTED]>

Use printk infrastructure to print out some debug info once VM crashes.

Signed-off-by: Xiantao Zhang <[EMAIL PROTECTED]>
Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/arch/ia64/kvm/mmio.c b/arch/ia64/kvm/mmio.c
index 7f1a858..21f63ff 100644
--- a/arch/ia64/kvm/mmio.c
+++ b/arch/ia64/kvm/mmio.c
@@ -66,31 +66,25 @@ void lsapic_write(struct kvm_vcpu *v, unsigned long addr,
 
switch (addr) {
case PIB_OFST_INTA:
-   /*panic_domain(NULL, "Undefined write on PIB INTA\n");*/
-   panic_vm(v);
+   panic_vm(v, "Undefined write on PIB INTA\n");
break;
case PIB_OFST_XTP:
if (length == 1) {
vlsapic_write_xtp(v, val);
} else {
-   /*panic_domain(NULL,
-   "Undefined write on PIB XTP\n");*/
-   panic_vm(v);
+   panic_vm(v, "Undefined write on PIB XTP\n");
}
break;
default:
if (PIB_LOW_HALF(addr)) {
-   /*lower half */
+   /*Lower half */
if (length != 8)
-   /*panic_domain(NULL,
-   "Can't LHF write with size %ld!\n",
-   length);*/
-   panic_vm(v);
+   panic_vm(v, "Can't LHF write with size %ld!\n",
+   length);
else
vlsapic_write_ipi(v, addr, val);
-   } else {   /*   upper half
-   printk("IPI-UHF write %lx\n",addr);*/
-   panic_vm(v);
+   } else {   /*Upper half */
+   panic_vm(v, "IPI-UHF write %lx\n", addr);
}
break;
}
@@ -108,22 +102,18 @@ unsigned long lsapic_read(struct kvm_vcpu *v, unsigned 
long addr,
if (length == 1) /* 1 byte load */
; /* There is no i8259, there is no INTA access*/
else
-   /*panic_domain(NULL,"Undefined read on PIB INTA\n"); */
-   panic_vm(v);
+   panic_vm(v, "Undefined read on PIB INTA\n");
 
break;
case PIB_OFST_XTP:
if (length == 1) {
result = VLSAPIC_XTP(v);
-   /* printk("read xtp %lx\n", result); */
} else {
-   /*panic_domain(NULL,
-   "Undefined read on PIB XTP\n");*/
-   panic_vm(v);
+   panic_vm(v, "Undefined read on PIB XTP\n");
}
break;
default:
-   panic_vm(v);
+   panic_vm(v, "Undefined addr access for lsapic!\n");
break;
}
return result;
@@ -162,7 +152,7 @@ static void mmio_access(struct kvm_vcpu *vcpu, u64 src_pa, 
u64 *dest,
/* it's necessary to ensure zero extending */
*dest = p->u.ioreq.data & (~0UL >> (64-(s*8)));
} else
-   panic_vm(vcpu);
+   panic_vm(vcpu, "Unhandled mmio access returned!\n");
 out:
local_irq_restore(psr);
return ;
@@ -324,7 +314,9 @@ void emulate_io_inst(struct kvm_vcpu *vcpu, u64 padr, u64 
ma)
return;
} else {
inst_type = -1;
-   panic_vm(vcpu);
+   panic_vm(vcpu, "Unsupported MMIO access instruction! \
+   Bunld[0]=0x%lx, Bundle[1]=0x%lx\n",
+   bundle.i64[0], bundle.i64[1]);
}
 
size = 1 << size;
@@ -335,7 +327,7 @@ void emulate_io_inst(struct kvm_vcpu *vcpu, u64 padr, u64 
ma)
if (inst_type == SL_INTEGER)
vcpu_set_gr(vcpu, inst.M1.r1, data, 0);
else
-   panic_vm(vcpu);
+   panic_vm(vcpu, "Unsupported instruction type!\n");
 
}
vcpu_increment_iip(vcpu);
diff --git a/arch/ia64/kvm/process.c b/arch/ia64/kvm/process.c
index 8008173..cefc349 100644
--- a/arch/ia64/kvm/process.c
+++ b/arch/ia64/kvm/process.c
@@ -527,7 +527,8 @@ void reflect_interruption(u64 ifa, u64 isr, u64 iim,
vector = vec2off[vec];
 
if (!(vpsr & IA64_PSR_IC) && (vector != IA64_DATA_NESTED_TLB_VECTOR)) {
-   panic_vm(vcpu);
+   panic_vm(vcpu, "Interruption with vector :0x%lx occurs "
+   "with psr.ic = 0\n", vector);
return;
}
 
@@ -586,7 +587,7 @@ static void set_pal_call_result(struct kvm_vcpu *vcpu)
vcpu_set_gr(vcpu, 10, p->u.pal_data.ret.v1, 0);
vcpu_set_gr(vcpu, 11, p->u

[PATCH] KVM: ia64: Add handler for crashed vmm

2008-11-23 Thread Avi Kivity
From: Xiantao Zhang <[EMAIL PROTECTED]>

Since vmm runs in an isolated address space and it is just a copy
of host's kvm-intel module, so once vmm crashes, we just crash all guests
running on it instead of crashing whole kernel.

Signed-off-by: Xiantao Zhang <[EMAIL PROTECTED]>
Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/arch/ia64/kvm/process.c b/arch/ia64/kvm/process.c
index cefc349..552d077 100644
--- a/arch/ia64/kvm/process.c
+++ b/arch/ia64/kvm/process.c
@@ -942,8 +942,20 @@ static void vcpu_do_resume(struct kvm_vcpu *vcpu)
ia64_set_pta(vcpu->arch.vhpt.pta.val);
 }
 
+static void vmm_sanity_check(struct kvm_vcpu *vcpu)
+{
+   struct exit_ctl_data *p = &vcpu->arch.exit_data;
+
+   if (!vmm_sanity && p->exit_reason != EXIT_REASON_DEBUG) {
+   panic_vm(vcpu, "Failed to do vmm sanity check,"
+   "it maybe caused by crashed vmm!!\n\n");
+   }
+}
+
 static void kvm_do_resume_op(struct kvm_vcpu *vcpu)
 {
+   vmm_sanity_check(vcpu); /*Guarantee vcpu runing on healthy vmm!*/
+
if (test_and_clear_bit(KVM_REQ_RESUME, &vcpu->requests)) {
vcpu_do_resume(vcpu);
return;
@@ -969,3 +981,11 @@ void vmm_transition(struct kvm_vcpu *vcpu)
1, 0, 0, 0, 0, 0);
kvm_do_resume_op(vcpu);
 }
+
+void vmm_panic_handler(u64 vec)
+{
+   struct kvm_vcpu *vcpu = current_vcpu;
+   vmm_sanity = 0;
+   panic_vm(vcpu, "Unexpected interruption occurs in VMM, vector:0x%lx\n",
+   vec2off[vec]);
+}
diff --git a/arch/ia64/kvm/vcpu.h b/arch/ia64/kvm/vcpu.h
index 0dad842..b2f12a5 100644
--- a/arch/ia64/kvm/vcpu.h
+++ b/arch/ia64/kvm/vcpu.h
@@ -741,5 +741,8 @@ void panic_vm(struct kvm_vcpu *v, const char *fmt, ...);
 
 extern u64 ia64_call_vsa(u64 proc, u64 arg1, u64 arg2, u64 arg3,
u64 arg4, u64 arg5, u64 arg6, u64 arg7);
+
+extern long vmm_sanity;
+
 #endif
 #endif /* __VCPU_H__ */
diff --git a/arch/ia64/kvm/vmm.c b/arch/ia64/kvm/vmm.c
index d3dc0b0..9eee5c0 100644
--- a/arch/ia64/kvm/vmm.c
+++ b/arch/ia64/kvm/vmm.c
@@ -32,6 +32,8 @@ MODULE_LICENSE("GPL");
 extern char kvm_ia64_ivt;
 extern fpswa_interface_t *vmm_fpswa_interface;
 
+long vmm_sanity = 1;
+
 struct kvm_vmm_info vmm_info = {
.module  = THIS_MODULE,
.vmm_entry   = vmm_entry,
diff --git a/arch/ia64/kvm/vmm_ivt.S b/arch/ia64/kvm/vmm_ivt.S
index c1d7251..50b4646 100644
--- a/arch/ia64/kvm/vmm_ivt.S
+++ b/arch/ia64/kvm/vmm_ivt.S
@@ -70,14 +70,12 @@
 # define PSR_DEFAULT_BITS   0
 #endif
 
-
 #define KVM_FAULT(n)\
 kvm_fault_##n:;  \
 mov r19=n;;  \
-br.sptk.many kvm_fault_##n; \
+br.sptk.many kvm_vmm_panic; \
 ;;  \
 
-
 #define KVM_REFLECT(n)\
 mov r31=pr;   \
 mov r19=n;   /* prepare to save predicates */ \
@@ -85,17 +83,26 @@
 ;;  \
 tbit.z p6,p7=r29,IA64_PSR_VM_BIT;   \
 (p7)br.sptk.many kvm_dispatch_reflection;\
-br.sptk.many kvm_panic;  \
-
+br.sptk.many kvm_vmm_panic;  \
 
-GLOBAL_ENTRY(kvm_panic)
-br.sptk.many kvm_panic
+GLOBAL_ENTRY(kvm_vmm_panic)
+KVM_SAVE_MIN_WITH_COVER_R19
+alloc r14=ar.pfs,0,0,1,0
+mov out0=r15
+adds r3=8,r2// set up second base pointer
 ;;
-END(kvm_panic)
-
-
-
-
+ssm psr.ic
+;;
+srlz.i  // guarantee that interruption collection is on
+;;
+//(p15) ssm psr.i   // restore psr.i
+addl [EMAIL PROTECTED](ia64_leave_hypervisor),gp
+;;
+KVM_SAVE_REST
+mov rp=r14
+;;
+br.call.sptk.many b6=vmm_panic_handler;
+END(kvm_vmm_panic)
 
 .section .text.ivt,"ax"
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM: ia64: Define printk function for kvm-intel module

2008-11-23 Thread Avi Kivity
From: Xiantao Zhang <[EMAIL PROTECTED]>

kvm-intel module is relocated to an isolated address space
with kernel, so it can't call host kernel's printk for debug
purpose. In the module, we implement the printk to output debug
info of vmm.

Signed-off-by: Xiantao Zhang <[EMAIL PROTECTED]>
Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
index 678e264..0560f3f 100644
--- a/arch/ia64/include/asm/kvm_host.h
+++ b/arch/ia64/include/asm/kvm_host.h
@@ -39,6 +39,7 @@
 #define EXIT_REASON_EXTERNAL_INTERRUPT 6
 #define EXIT_REASON_IPI7
 #define EXIT_REASON_PTC_G  8
+#define EXIT_REASON_DEBUG  20
 
 /*Define vmm address space and vm data space.*/
 #define KVM_VMM_SIZE (__IA64_UL_CONST(16)<<20)
@@ -126,6 +127,8 @@
KVM_MEM_DIRTY_LOG_SIZE) / sizeof(struct kvm_vcpu_data)
 #define KVM_MAX_MEM_SIZE (KVM_P2M_SIZE >> 3 << PAGE_SHIFT)
 
+#define VMM_LOG_LEN 256
+
 #include 
 #include 
 #include 
@@ -437,6 +440,7 @@ struct kvm_vcpu_arch {
 
unsigned long opcode;
unsigned long cause;
+   char log_buf[VMM_LOG_LEN];
union context host;
union context guest;
 };
diff --git a/arch/ia64/kvm/Makefile b/arch/ia64/kvm/Makefile
index 92cef66..76464dc 100644
--- a/arch/ia64/kvm/Makefile
+++ b/arch/ia64/kvm/Makefile
@@ -60,7 +60,7 @@ obj-$(CONFIG_KVM) += kvm.o
 
 CFLAGS_vcpu.o += -mfixed-range=f2-f5,f12-f127
 kvm-intel-objs = vmm.o vmm_ivt.o trampoline.o vcpu.o optvfault.o mmio.o \
-   vtlb.o process.o
+   vtlb.o process.o kvm_lib.o
 #Add link memcpy and memset to avoid possible structure assignment error
 kvm-intel-objs += memcpy.o memset.o
 obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 70eb829..b4d24e2 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -474,6 +474,13 @@ static int handle_external_interrupt(struct kvm_vcpu *vcpu,
return 1;
 }
 
+static int handle_vcpu_debug(struct kvm_vcpu *vcpu,
+   struct kvm_run *kvm_run)
+{
+   printk("VMM: %s", vcpu->arch.log_buf);
+   return 1;
+}
+
 static int (*kvm_vti_exit_handlers[])(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run) = {
[EXIT_REASON_VM_PANIC]  = handle_vm_error,
@@ -485,6 +492,7 @@ static int (*kvm_vti_exit_handlers[])(struct kvm_vcpu *vcpu,
[EXIT_REASON_EXTERNAL_INTERRUPT]= handle_external_interrupt,
[EXIT_REASON_IPI]   = handle_ipi,
[EXIT_REASON_PTC_G] = handle_global_purge,
+   [EXIT_REASON_DEBUG] = handle_vcpu_debug,
 
 };
 
diff --git a/arch/ia64/kvm/kvm_lib.c b/arch/ia64/kvm/kvm_lib.c
new file mode 100644
index 000..a85cb61
--- /dev/null
+++ b/arch/ia64/kvm/kvm_lib.c
@@ -0,0 +1,15 @@
+/*
+ * kvm_lib.c: Compile some libraries for kvm-intel module.
+ *
+ * Just include kernel's library, and disable symbols export.
+ * Copyright (C) 2008, Intel Corporation.
+ * Xiantao Zhang  ([EMAIL PROTECTED])
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#undef CONFIG_MODULES
+#include "../../../lib/vsprintf.c"
+#include "../../../lib/ctype.c"
diff --git a/arch/ia64/kvm/vmm.c b/arch/ia64/kvm/vmm.c
index 2275bf4..9577795 100644
--- a/arch/ia64/kvm/vmm.c
+++ b/arch/ia64/kvm/vmm.c
@@ -62,5 +62,31 @@ void vmm_spin_unlock(spinlock_t *lock)
 {
_vmm_raw_spin_unlock(lock);
 }
+
+static void vcpu_debug_exit(struct kvm_vcpu *vcpu)
+{
+   struct exit_ctl_data *p = &vcpu->arch.exit_data;
+   long psr;
+
+   local_irq_save(psr);
+   p->exit_reason = EXIT_REASON_DEBUG;
+   vmm_transition(vcpu);
+   local_irq_restore(psr);
+}
+
+asmlinkage int printk(const char *fmt, ...)
+{
+   struct kvm_vcpu *vcpu = current_vcpu;
+   va_list args;
+   int r;
+
+   memset(vcpu->arch.log_buf, 0, VMM_LOG_LEN);
+   va_start(args, fmt);
+   r = vsnprintf(vcpu->arch.log_buf, VMM_LOG_LEN, fmt, args);
+   va_end(args);
+   vcpu_debug_exit(vcpu);
+   return r;
+}
+
 module_init(kvm_vmm_init)
 module_exit(kvm_vmm_exit)
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM: MMU: fix sync of ptes addressed at owner pagetable

2008-11-23 Thread Avi Kivity
From: Marcelo Tosatti <[EMAIL PROTECTED]>

During page sync, if a pagetable contains a self referencing pte (that
points to the pagetable), the corresponding spte may be marked as
writable even though all mappings are supposed to be write protected.

Fix by clearing page unsync before syncing individual sptes.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>
Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 7d77730..fa3486d 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1046,13 +1046,13 @@ static int kvm_sync_page(struct kvm_vcpu *vcpu, struct 
kvm_mmu_page *sp)
}
 
rmap_write_protect(vcpu->kvm, sp->gfn);
+   kvm_unlink_unsync_page(vcpu->kvm, sp);
if (vcpu->arch.mmu.sync_page(vcpu, sp)) {
kvm_mmu_zap_page(vcpu->kvm, sp);
return 1;
}
 
kvm_mmu_flush_tlb(vcpu);
-   kvm_unlink_unsync_page(vcpu->kvm, sp);
return 0;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html