[COMMIT master] qemu-kvm: fix ioapic savevm

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

We setup old version values in pre_load until patch with
adds version_id to post_load got merged

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/hw/ioapic.c b/hw/ioapic.c
index 7628da0..527c989 100644
--- a/hw/ioapic.c
+++ b/hw/ioapic.c
@@ -240,63 +240,48 @@ static void kvm_kernel_ioapic_load_from_user(IOAPICState 
*s)
 #endif
 }
 
-static void ioapic_save(QEMUFile *f, void *opaque)
+static void ioapic_pre_save(const void *opaque)
 {
-IOAPICState *s = opaque;
-int i;
-
+IOAPICState *s = (void *)opaque;
+ 
 if (kvm_enabled()  qemu_kvm_irqchip_in_kernel()) {
 kvm_kernel_ioapic_save_to_user(s);
 }
-
-qemu_put_8s(f, s-id);
-qemu_put_8s(f, s-ioregsel);
-qemu_put_be64s(f, s-base_address);
-qemu_put_be32s(f, s-irr);
-for (i = 0; i  IOAPIC_NUM_PINS; i++) {
-qemu_put_be64s(f, s-ioredtbl[i]);
-}
 }
 
-static int ioapic_load(QEMUFile *f, void *opaque, int version_id)
+static int ioapic_pre_load(void *opaque)
 {
 IOAPICState *s = opaque;
-int i;
 
-if (version_id  1 || version_id  2)
-return -EINVAL;
+/* in case we are doing version 1, we just set these to sane values */
+s-base_address = IOAPIC_DEFAULT_BASE_ADDRESS;
+s-irr = 0;
+return 0;
+}
 
-qemu_get_8s(f, s-id);
-qemu_get_8s(f, s-ioregsel);
-if (version_id == 2) {
-  /* for version 2, we get this data off of the wire */
-  qemu_get_be64s(f, s-base_address);
-  qemu_get_be32s(f, s-irr);
-}
-else {
-  /* in case we are doing version 1, we just set these to sane values */
-  s-base_address = IOAPIC_DEFAULT_BASE_ADDRESS;
-  s-irr = 0;
-}
-for (i = 0; i  IOAPIC_NUM_PINS; i++) {
-qemu_get_be64s(f, s-ioredtbl[i]);
-}
+static int ioapic_post_load(void *opaque)
+{
+IOAPICState *s = opaque;
 
 if (kvm_enabled()  qemu_kvm_irqchip_in_kernel()) {
 kvm_kernel_ioapic_load_from_user(s);
 }
-
 return 0;
 }
 
 static const VMStateDescription vmstate_ioapic = {
 .name = ioapic,
-.version_id = 1,
+.version_id = 2,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
+.pre_load = ioapic_pre_load,
+.post_load = ioapic_post_load,
+.pre_save = ioapic_pre_save,
 .fields  = (VMStateField []) {
 VMSTATE_UINT8(id, IOAPICState),
 VMSTATE_UINT8(ioregsel, IOAPICState),
+VMSTATE_UINT64_V(base_address, IOAPICState, 2),
+VMSTATE_UINT32_V(irr, IOAPICState, 2),
 VMSTATE_UINT64_ARRAY(ioredtbl, IOAPICState, IOAPIC_NUM_PINS),
 VMSTATE_END_OF_LIST()
 }
@@ -343,9 +328,7 @@ qemu_irq *ioapic_init(void)
ioapic_mem_write, s);
 cpu_register_physical_memory(0xfec0, 0x1000, io_memory);
 
-#if 0
 vmstate_register(0, vmstate_ioapic, s);
-#endif
 qemu_register_reset(ioapic_reset, s);
 irq = qemu_allocate_irqs(ioapic_set_irq, s, IOAPIC_NUM_PINS);
 
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Add test device

2009-09-21 Thread Avi Kivity
From: Gerd Hoffmann kra...@redhat.com

Add a test device which supports the kvmctl ioports, for running the test
suite.

Usage:

  qemu
 -chardev file,path=/log/file/some/where,id=testlog
 -device testdev,chardev=testlog

Signed-off-by: Gerd Hoffmann kra...@redhat.com
Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/Makefile.target b/Makefile.target
index c8c9568..a08e432 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -216,6 +216,7 @@ obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o 
wdt_ib700.o
 obj-i386-y += extboot.o
 obj-i386-y += piix4.o
 obj-i386-y += ne2000-isa.o
+obj-i386-y += testdev.o
 ifeq ($(USE_KVM_PIT), 1)
 obj-i386-y += i8254-kvm.o
 endif
diff --git a/hw/testdev.c b/hw/testdev.c
new file mode 100644
index 000..199731e
--- /dev/null
+++ b/hw/testdev.c
@@ -0,0 +1,55 @@
+#include hw.h
+#include qdev.h
+#include isa.h
+
+struct testdev {
+ISADevice dev;
+CharDriverState *chr;
+};
+
+static void test_device_serial_write(void *opaque, uint32_t addr, uint32_t 
data)
+{
+struct testdev *dev = opaque;
+uint8_t buf[1] = { data };
+
+if (dev-chr) {
+qemu_chr_write(dev-chr, buf, 1);
+}
+}
+
+static void test_device_exit(void *opaque, uint32_t addr, uint32_t data)
+{
+exit(data);
+}
+
+static uint32_t test_device_memsize_read(void *opaque, uint32_t addr)
+{
+return ram_size;
+}
+
+static int init_test_device(ISADevice *isa)
+{
+struct testdev *dev = DO_UPCAST(struct testdev, dev, isa);
+
+register_ioport_write(0xf1, 1, 1, test_device_serial_write, dev);
+register_ioport_write(0xf4, 1, 4, test_device_exit, dev);
+register_ioport_read(0xd1, 1, 4, test_device_memsize_read, dev);
+return 0;
+}
+
+static ISADeviceInfo testdev_info = {
+.qdev.name  = testdev,
+.qdev.size  = sizeof(struct testdev),
+.init   = init_test_device,
+.qdev.props = (Property[]) {
+DEFINE_PROP_CHR(chardev, struct testdev, chr),
+DEFINE_PROP_END_OF_LIST(),
+},
+};
+
+static void testdev_register_devices(void)
+{
+isa_qdev_register(testdev_info);
+}
+
+device_init(testdev_register_devices)
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Merge branch 'upstream-merge'

2009-09-21 Thread Avi Kivity
From: Marcelo Tosatti mtosa...@redhat.com

* upstream-merge: (128 commits)
  Fix Linux task preemption on Versatile board
  pflash_cfi01: Correct debug build, no functional changes.
  ne2000-isa: Do not free memory owned by qdev
  alsa: Use proper value when testing returned events in alsa_poll_handler
  alsa/oss: Remove fd transfer handlers before closing oss/alsa fd/handle
  configure: change found to find
  Revert Fix Sparc/Linux host breakage by 
df70204db53e3611af986f434e74a882bce190ca
  Fix sparc.ld
  audio: Fix typo that broke QEMU_AUDIO_ADC_TRY_POLL
  Fix Sparc/Linux host breakage by df70204db53e3611af986f434e74a882bce190ca
  Sparc64: make system bus parent of PCI bus
  x86: move a declaration to header
  x86: add 'const'
  oss: Simplify mmap code
  oss: OSS v4 support
  i386: Drop redundant kvm_enabled test
  Make string arrays used to convert numbers to strings when DEBUG_EEPRO100 is 
enabled const.
  Fix xen build after sys-queue renaming
  Add configure option to compile user targets as PIE
  Fix text relocations in linux-user targets
  ...

Signed-off-by: Marcelo Tosatti mtosa...@redhat.com
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: Set up a default stack

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

multiboot doesn't give us any stack, so we need to set one up.

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/cstart64.S b/kvm/user/test/x86/cstart64.S
index 432a3dc..4f116f9 100644
--- a/kvm/user/test/x86/cstart64.S
+++ b/kvm/user/test/x86/cstart64.S
@@ -69,6 +69,7 @@ tss_end:
 .section .init
 
 .code32
+   mov $stacktop, %esp
call prepare_64
jmpl $8, $start64
 
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: Map 4GB of memory

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Needed so the APIC can be accessed at address 0xfee0.

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/cstart64.S b/kvm/user/test/x86/cstart64.S
index 805938b..3f193a3 100644
--- a/kvm/user/test/x86/cstart64.S
+++ b/kvm/user/test/x86/cstart64.S
@@ -22,14 +22,17 @@ ring0stacktop:
 .align 4096
 ptl2:
 i = 0
-   .rept 512
+   .rept 512 * 4
.quad 0x1e7 | (i  21)
i = i + 1
.endr
 
 .align 4096
 ptl3:
-   .quad ptl2 + 7
+   .quad ptl2 + 7 + 0 * 4096
+   .quad ptl2 + 7 + 1 * 4096
+   .quad ptl2 + 7 + 2 * 4096
+   .quad ptl2 + 7 + 3 * 4096
 
 .align 4096
 ptl4:
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: Remove smp support from access.c

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Doesn't do anthing anyway.

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/access.c b/kvm/user/test/x86/access.c
index 272a4ef..5eadff8 100644
--- a/kvm/user/test/x86/access.c
+++ b/kvm/user/test/x86/access.c
@@ -1,6 +1,7 @@
 
 #include libcflat.h
-#include smp.h
+
+#define smp_id() 0
 
 #define true 1
 #define false 0
@@ -598,7 +599,6 @@ int main()
 int r;
 
 printf(starting test\n\n);
-smp_init((void(*)(void))ac_test_run);
 r = ac_test_run();
 return r ? 0 : 1;
 }
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: use real APIC instead of fake APIC

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

smp temporarily disabled

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/cstart64.S b/kvm/user/test/x86/cstart64.S
index 3f193a3..912bcf8 100644
--- a/kvm/user/test/x86/cstart64.S
+++ b/kvm/user/test/x86/cstart64.S
@@ -1,5 +1,5 @@
 
-#include fake-apic.h
+#include apic.h
 
 boot_idt = 0
 
@@ -131,8 +131,9 @@ start64:
 load_tss:
mov $0, %eax
mov %ax, %ss
-   mov $(APIC_BASE + APIC_REG_ID), %dx
-   in %dx, %eax
+   mov $(APIC_DEFAULT_PHYS_BASE + APIC_ID), %eax
+   mov (%rax), %eax
+   shr $24, %eax
mov %eax, %ebx
shl $4, %ebx
mov $((tss_end - tss) / max_cpus), %edx
@@ -150,6 +151,7 @@ load_tss:
ret
 
 smp_init:
+#if 0
lea boot_idt + ipi_vector * 8, %rdi
mov $smp_init_ipi, %eax
mov %ax, (%rdi)
@@ -178,4 +180,5 @@ smp_loop:
inc %esi
jmp smp_loop
 smp_init_done:
+#endif
ret
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: Add vmcall latency test

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c
index 364837f..bd1895f 100644
--- a/kvm/user/test/x86/vmexit.c
+++ b/kvm/user/test/x86/vmexit.c
@@ -30,11 +30,19 @@ static void cpuid(void)
  : : : eax, ecx, edx);
 }
 
+static void vmcall(void)
+{
+   unsigned long a = 0, b, c, d;
+
+   asm volatile (vmcall : +a(a), =b(b), =c(c), =d(d));
+}
+
 static struct test {
void (*func)(void);
const char *name;
 } tests[] = {
{ cpuid, cpuid, },
+   { vmcall, vmcall, },
 };
 
 static void do_test(struct test *test)
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: port readmode tests to multiboot

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/realmode.c b/kvm/user/test/x86/realmode.c
index f9e303f..9bf6cb0 100644
--- a/kvm/user/test/x86/realmode.c
+++ b/kvm/user/test/x86/realmode.c
@@ -549,7 +549,7 @@ void test_null(void)
print_serial(null test: FAIL\n);
 }
 
-void start(void)
+void realmode_start(void)
 {
test_null();
 
@@ -570,23 +570,55 @@ void start(void)
exit(0);
 }
 
+unsigned long long r_gdt[] = { 0, 0x9b00, 0x9300 };
+
+struct __attribute__((packed)) {
+   unsigned short limit;
+   void *base;
+} r_gdt_descr = { sizeof(r_gdt) - 1, r_gdt };
+
 asm(
+   .section .init \n\t
+
+   .code32 \n\t
+
+   mb_magic = 0x1BADB002 \n\t
+   mb_flags = 0x0 \n\t
+
+   # multiboot header \n\t
+   .long mb_magic, mb_flags, 0 - (mb_magic + mb_flags) \n\t
+
+   .globl start \n\t
.data \n\t
. = . + 4096 \n\t
stacktop: \n\t
+
.text \n\t
-   init: \n\t
+   start: \n\t
+   lgdt r_gdt_descr \n\t
+   ljmp $8, $1f; 1: \n\t
+   .code16gcc \n\t
+   mov $16, %eax \n\t
+   mov %ax, %ds \n\t
+   mov %ax, %es \n\t
+   mov %ax, %fs \n\t
+   mov %ax, %gs \n\t
+   mov %ax, %ss \n\t
+   mov %cr0, %eax \n\t
+   btc $0, %eax \n\t
+   mov %eax, %cr0 \n\t
+   ljmp $0, $realmode_entry \n\t
+
+   realmode_entry: \n\t
+
xor %ax, %ax \n\t
mov %ax, %ds \n\t
mov %ax, %es \n\t
mov %ax, %ss \n\t
-   mov $0x4000, %cx \n\t
-   xor %esi, %esi \n\t
-   mov %esi, %edi \n\t
-   rep/addr32/cs/movsl \n\t
+   mov %ax, %fs \n\t
+   mov %ax, %gs \n\t
mov $stacktop, %sp\n\t
-   ljmp $0, $start \n\t
-   .pushsection .boot, \ax\ \n\t
-   ljmp $0xf000, $init \n\t
-   .popsection
+   ljmp $0, $realmode_start \n\t
+
+   .code16gcc \n\t
);
diff --git a/kvm/user/test/x86/realmode.lds b/kvm/user/test/x86/realmode.lds
index c9cdd7d..c7386b8 100644
--- a/kvm/user/test/x86/realmode.lds
+++ b/kvm/user/test/x86/realmode.lds
@@ -1,16 +1,12 @@
-OUTPUT_FORMAT(binary)
-
 SECTIONS
 {
-. = 0;
+. = 16K;
 stext = .;
 .text : { *(.init) *(.text) }
 . = ALIGN(4K);
 .data : { *(.data) *(.rodata*) }
 . = ALIGN(16);
 .bss : { *(.bss) }
-. = 0xfff0;
-.boot : { *(.boot) }
 edata = .;
 }
 
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: Mask PIC interrupts before APIC test

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

We aren't ready to handle PIC interrupts, so mask them.

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/apic.c b/kvm/user/test/x86/apic.c
index 7794615..b712ef8 100644
--- a/kvm/user/test/x86/apic.c
+++ b/kvm/user/test/x86/apic.c
@@ -102,6 +102,11 @@ static idt_entry_t idt[256];
 static int g_fail;
 static int g_tests;
 
+static void outb(unsigned char data, unsigned short port)
+{
+asm volatile (out %0, %1 : : a(data), d(port));
+}
+
 static void report(const char *msg, int pass)
 {
 ++g_tests;
@@ -325,9 +330,16 @@ static void test_ioapic_simultaneous(void)
 
 static void enable_apic(void)
 {
+printf(enabling apic\n);
 apic_write(0xf0, 0x1ff); /* spurious vector register */
 }
 
+static void mask_pic_interrupts(void)
+{
+outb(0xff, 0x21);
+outb(0xff, 0xa1);
+}
+
 int main()
 {
 setup_vm();
@@ -337,6 +349,7 @@ int main()
 
 test_lapic_existence();
 
+mask_pic_interrupts();
 enable_apic();
 init_idt();
 
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: fix realmode test print_serial() direction flag

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Clear the direction flag to get the correct output.

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/realmode.c b/kvm/user/test/x86/realmode.c
index 0db09b8..f9e303f 100644
--- a/kvm/user/test/x86/realmode.c
+++ b/kvm/user/test/x86/realmode.c
@@ -26,7 +26,7 @@ static void print_serial(const char *buf)
 {
unsigned long len = strlen(buf);
 
-   asm volatile (addr32/rep/outsb : +S(buf), +c(len) : d(0xf1));
+   asm volatile (cld; addr32/rep/outsb : +S(buf), +c(len) : 
d(0xf1));
 }
 
 static void exit(int code)
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: Allow adding mode vmexit latency tests

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Make the latency test run on an array of function pointers, which
can be expanded with more tests.

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c
index 981d6c1..364837f 100644
--- a/kvm/user/test/x86/vmexit.c
+++ b/kvm/user/test/x86/vmexit.c
@@ -24,16 +24,40 @@ static inline unsigned long long rdtsc()
 #  define R e
 #endif
 
-int main()
+static void cpuid(void)
+{
+   asm volatile (push %%R bx; cpuid; pop %%R bx
+ : : : eax, ecx, edx);
+}
+
+static struct test {
+   void (*func)(void);
+   const char *name;
+} tests[] = {
+   { cpuid, cpuid, },
+};
+
+static void do_test(struct test *test)
 {
int i;
unsigned long long t1, t2;
+void (*func)(void) = test-func;
 
t1 = rdtsc();
for (i = 0; i  N; ++i)
-   asm volatile (push %%R bx; cpuid; pop %%R bx
- : : : eax, ecx, edx);
+func();
t2 = rdtsc();
-   printf(vmexit latency: %d\n, (int)((t2 - t1) / N));
+   printf(%s %d\n, test-name, (int)((t2 - t1) / N));
+}
+
+#define ARRAY_SIZE(_x) (sizeof(_x) / sizeof((_x)[0]))
+
+int main(void)
+{
+   int i;
+
+   for (i = 0; i  ARRAY_SIZE(tests); ++i)
+   do_test(tests[i]);
+
return 0;
 }
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: add x2apic test

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/apic.c b/kvm/user/test/x86/apic.c
index fdeec4c..504def2 100644
--- a/kvm/user/test/x86/apic.c
+++ b/kvm/user/test/x86/apic.c
@@ -9,6 +9,7 @@ typedef unsigned char u8;
 typedef unsigned short u16;
 typedef unsigned u32;
 typedef unsigned long ulong;
+typedef unsigned long long u64;
 
 typedef struct {
 unsigned short offset0;
@@ -147,6 +148,31 @@ static const struct apic_ops xapic_ops = {
 
 static const struct apic_ops *apic_ops = xapic_ops;
 
+static u32 x2apic_read(unsigned reg)
+{
+unsigned a, d;
+
+asm volatile (rdmsr : =a(a), =d(d) : c(APIC_BASE_MSR + reg/16));
+return a | (u64)d  32;
+}
+
+static void x2apic_write(unsigned reg, u32 val)
+{
+asm volatile (wrmsr : : a(val), d(0), c(APIC_BASE_MSR + reg/16));
+}
+
+static void x2apic_icr_write(u32 val, u32 dest)
+{
+asm volatile (wrmsr : : a(val), d(dest),
+  c(APIC_BASE_MSR + APIC_ICR/16));
+}
+
+static const struct apic_ops x2apic_ops = {
+.reg_read = x2apic_read,
+.reg_write = x2apic_write,
+.icr_write = x2apic_icr_write,
+};
+
 static u32 apic_read(unsigned reg)
 {
 return apic_ops-reg_read(reg);
@@ -171,6 +197,25 @@ static void test_lapic_existence(void)
 report(apic existence, (u16)lvr == 0x14);
 }
 
+#define MSR_APIC_BASE 0x001b
+
+static void enable_x2apic(void)
+{
+unsigned a, b, c, d;
+
+asm (cpuid : =a(a), =b(b), =c(c), =d(d) : 0(1));
+
+if (c  (1  21)) {
+asm (rdmsr : =a(a), =d(d) : c(MSR_APIC_BASE));
+a |= 1  10;
+asm (wrmsr : : a(a), d(d), c(MSR_APIC_BASE));
+apic_ops = x2apic_ops;
+printf(x2apic enabled\n);
+} else {
+printf(x2apic not detected\n);
+}
+}
+
 static u16 read_cs(void)
 {
 u16 v;
@@ -388,6 +433,7 @@ int main()
 
 mask_pic_interrupts();
 enable_apic();
+enable_x2apic();
 init_idt();
 
 test_self_ipi();
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: vm: map mmio 1:1

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

With this assumption, the apic code will be able to run either before or after
the vm is set up.

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/vm.c b/kvm/user/test/x86/vm.c
index 03c7354..ec9c145 100644
--- a/kvm/user/test/x86/vm.c
+++ b/kvm/user/test/x86/vm.c
@@ -189,6 +189,9 @@ static void setup_mmu(unsigned long len)
 unsigned long *cr3 = alloc_page();
 unsigned long phys = 0;
 
+if (len  (1ul  32))
+len = 1ul  32;  /* map mmio 1:1 */
+
 memset(cr3, 0, PAGE_SIZE);
 while (phys + LARGE_PAGE_SIZE = len) {
install_large_page(cr3, phys, (void *)phys);
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: Add fwcfg interface for getting the cpu count

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/lib/x86/fwcfg.c b/kvm/user/test/lib/x86/fwcfg.c
index a9a2ce2..2cf7cec 100644
--- a/kvm/user/test/lib/x86/fwcfg.c
+++ b/kvm/user/test/lib/x86/fwcfg.c
@@ -33,3 +33,8 @@ uint64_t fwcfg_get_u64(unsigned index)
 {
 return fwcfg_get_u(index, 8);
 }
+
+unsigned fwcfg_get_nb_cpus(void)
+{
+return fwcfg_get_u16(FW_CFG_NB_CPUS);
+}
diff --git a/kvm/user/test/lib/x86/fwcfg.h b/kvm/user/test/lib/x86/fwcfg.h
index c7245e2..e0836ca 100644
--- a/kvm/user/test/lib/x86/fwcfg.h
+++ b/kvm/user/test/lib/x86/fwcfg.h
@@ -38,5 +38,7 @@ uint16_t fwcfg_get_u16(unsigned index);
 uint32_t fwcfg_get_u32(unsigned index);
 uint64_t fwcfg_get_u64(unsigned index);
 
+unsigned fwcfg_get_nb_cpus(void);
+
 #endif
 
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: initialize apic/x2apic on all processors

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/cstart64.S b/kvm/user/test/x86/cstart64.S
index a55ad50..54b721f 100644
--- a/kvm/user/test/x86/cstart64.S
+++ b/kvm/user/test/x86/cstart64.S
@@ -148,6 +148,8 @@ ap_start32:
 .code64
 ap_start64:
call load_tss
+   call enable_apic
+   call enable_x2apic
sti
nop
 
@@ -156,7 +158,10 @@ ap_start64:
 
 start64:
call load_tss
+   call mask_pic_interrupts
+   call enable_apic
call smp_init
+   call enable_x2apic
call main
mov %eax, %edi
call exit
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: add support for the firmware configuration interface

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/config-x86-common.mak b/kvm/user/config-x86-common.mak
index 2f59bb5..22a18b2 100644
--- a/kvm/user/config-x86-common.mak
+++ b/kvm/user/config-x86-common.mak
@@ -11,6 +11,8 @@ cflatobjs += \
test/lib/x86/io.o \
test/lib/x86/smp.o
 
+cflatobjs += test/lib/x86/fwcfg.o
+
 $(libcflat): LDFLAGS += -nostdlib
 $(libcflat): CFLAGS += -ffreestanding -I test/lib
 
diff --git a/kvm/user/test/lib/x86/fwcfg.c b/kvm/user/test/lib/x86/fwcfg.c
new file mode 100644
index 000..a9a2ce2
--- /dev/null
+++ b/kvm/user/test/lib/x86/fwcfg.c
@@ -0,0 +1,35 @@
+#include fwcfg.h
+
+uint64_t fwcfg_get_u(uint16_t index, int bytes)
+{
+uint64_t r = 0;
+uint8_t b;
+int i;
+
+asm volatile (out %0, %1 : : a(index), d((uint16_t)BIOS_CFG_IOPORT));
+for (i = 0; i  bytes; ++i) {
+asm volatile (in %1, %0 : =a(b) : d((uint16_t)(BIOS_CFG_IOPORT + 
1)));
+r |= (uint64_t)b  (i * 8);
+}
+return r;
+}
+
+uint8_t fwcfg_get_u8(unsigned index)
+{
+return fwcfg_get_u(index, 1);
+}
+
+uint16_t fwcfg_get_u16(unsigned index)
+{
+return fwcfg_get_u(index, 2);
+}
+
+uint32_t fwcfg_get_u32(unsigned index)
+{
+return fwcfg_get_u(index, 4);
+}
+
+uint64_t fwcfg_get_u64(unsigned index)
+{
+return fwcfg_get_u(index, 8);
+}
diff --git a/kvm/user/test/lib/x86/fwcfg.h b/kvm/user/test/lib/x86/fwcfg.h
new file mode 100644
index 000..c7245e2
--- /dev/null
+++ b/kvm/user/test/lib/x86/fwcfg.h
@@ -0,0 +1,42 @@
+#ifndef FWCFG_H
+#define FWCFG_H
+
+#include stdint.h
+
+#define FW_CFG_SIGNATURE0x00
+#define FW_CFG_ID   0x01
+#define FW_CFG_UUID 0x02
+#define FW_CFG_RAM_SIZE 0x03
+#define FW_CFG_NOGRAPHIC0x04
+#define FW_CFG_NB_CPUS  0x05
+#define FW_CFG_MACHINE_ID   0x06
+#define FW_CFG_KERNEL_ADDR  0x07
+#define FW_CFG_KERNEL_SIZE  0x08
+#define FW_CFG_KERNEL_CMDLINE   0x09
+#define FW_CFG_INITRD_ADDR  0x0a
+#define FW_CFG_INITRD_SIZE  0x0b
+#define FW_CFG_BOOT_DEVICE  0x0c
+#define FW_CFG_NUMA 0x0d
+#define FW_CFG_BOOT_MENU0x0e
+#define FW_CFG_MAX_CPUS 0x0f
+#define FW_CFG_MAX_ENTRY0x10
+
+#define FW_CFG_WRITE_CHANNEL0x4000
+#define FW_CFG_ARCH_LOCAL   0x8000
+#define FW_CFG_ENTRY_MASK   ~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL)
+
+#define FW_CFG_INVALID  0x
+
+#define BIOS_CFG_IOPORT 0x510
+
+#define FW_CFG_ACPI_TABLES (FW_CFG_ARCH_LOCAL + 0)
+#define FW_CFG_SMBIOS_ENTRIES (FW_CFG_ARCH_LOCAL + 1)
+#define FW_CFG_IRQ0_OVERRIDE (FW_CFG_ARCH_LOCAL + 2)
+
+uint8_t fwcfg_get_u8(unsigned index);
+uint16_t fwcfg_get_u16(unsigned index);
+uint32_t fwcfg_get_u32(unsigned index);
+uint64_t fwcfg_get_u64(unsigned index);
+
+#endif
+
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: Use xapic_write() to enable xapic()

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

apic_write() depends on apic_ops, which is shared among cpus and
can be modified if another cpu enabled x2apic.  Use xapic_write()
which is race-proof.

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/lib/x86/apic.c b/kvm/user/test/lib/x86/apic.c
index 16e51bc..1fc3888 100644
--- a/kvm/user/test/lib/x86/apic.c
+++ b/kvm/user/test/lib/x86/apic.c
@@ -139,7 +139,7 @@ void ioapic_write_redir(unsigned line, ioapic_redir_entry_t 
e)
 void enable_apic(void)
 {
 printf(enabling apic\n);
-apic_write(0xf0, 0x1ff); /* spurious vector register */
+xapic_write(0xf0, 0x1ff); /* spurious vector register */
 }
 
 void mask_pic_interrupts(void)
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Remove unused function.

2009-09-21 Thread Avi Kivity
From: Gleb Natapov g...@redhat.com

kvm_arch_update_regs_for_sipi() is not used anymore.

Signed-off-by: Gleb Natapov g...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/qemu-kvm-ia64.c b/qemu-kvm-ia64.c
index 062fbd4..d26c2a9 100644
--- a/qemu-kvm-ia64.c
+++ b/qemu-kvm-ia64.c
@@ -55,10 +55,6 @@ int kvm_arch_try_push_interrupts(void *opaque)
 return 1;
 }
 
-void kvm_arch_update_regs_for_sipi(CPUState *env)
-{
-}
-
 int kvm_arch_insert_sw_breakpoint(CPUState *current_env,
   struct kvm_sw_breakpoint *bp)
 {
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index f80d82b..ee678df 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1436,16 +1436,6 @@ void kvm_arch_push_nmi(void *opaque)
 }
 #endif /* KVM_CAP_USER_NMI */
 
-void kvm_arch_update_regs_for_sipi(CPUState *env)
-{
-SegmentCache cs = env-segs[R_CS];
-
-kvm_arch_save_regs(env);
-env-segs[R_CS] = cs;
-env-eip = 0;
-kvm_arch_load_regs(env);
-}
-
 void kvm_arch_cpu_reset(CPUState *env)
 {
 kvm_arch_load_regs(env);
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 0091a16..44e0665 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -1010,7 +1010,6 @@ int kvm_arch_has_work(CPUState *env);
 void kvm_arch_process_irqchip_events(CPUState *env);
 int kvm_arch_try_push_interrupts(void *opaque);
 void kvm_arch_push_nmi(void *opaque);
-void kvm_arch_update_regs_for_sipi(CPUState *env);
 void kvm_arch_cpu_reset(CPUState *env);
 int kvm_set_boot_cpu_id(uint32_t id);
 
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] compatfd is included before, and it is compiled unconditionally

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/Makefile b/Makefile
index 6a9ca7c..88b39bd 100644
--- a/Makefile
+++ b/Makefile
@@ -78,10 +78,6 @@ block-nested-$(CONFIG_CURL) += curl.o
 
 block-obj-y +=  $(addprefix block/, $(block-nested-y))
 
-ifdef CONFIG_AIO
-block-obj-y += compatfd.o
-endif
-
 ##
 # libqemu_common.a: Target independent part of system emulation. The
 # long term path is to suppress *all* target specific code in case of
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Make cpu runnable after sipi

2009-09-21 Thread Avi Kivity
From: Gleb Natapov g...@redhat.com

Signed-off-by: Gleb Natapov g...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/hw/apic.c b/hw/apic.c
index 918b28c..5ed5c98 100644
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -509,8 +509,9 @@ void apic_init_reset(CPUState *env)
 
 env-halted = !(s-apicbase  MSR_IA32_APICBASE_BSP);
 #ifdef KVM_CAP_MP_STATE
-env-mp_state
-= env-halted ? KVM_MP_STATE_INIT_RECEIVED : KVM_MP_STATE_RUNNABLE;
+if (kvm_irqchip_in_kernel(kvm_context))
+env-mp_state
+= env-halted ? KVM_MP_STATE_UNINITIALIZED : KVM_MP_STATE_RUNNABLE;
 #endif
 }
 
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Remove merge artifacts

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

CFLAGS and LDFLAGS are defined on config.mak
LDFLAGS_BASE is not used anywhere
DEPLIBS are not defined anywhere

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/Makefile.target b/Makefile.target
index a08e432..5fad812 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -1,13 +1,8 @@
 # -*- Mode: makefile -*-
 
-CFLAGS=
-LDFLAGS=
-
 include config.mak
 include $(SRC_PATH)/rules.mak
 
-LDFLAGS_BASE:=$(LDFLAGS)
-
 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
 QEMU_CFLAGS+= -I.. -I$(TARGET_PATH) -DNEED_CPU_H
@@ -347,9 +342,6 @@ monitor.o: qemu-monitor.h
 
 ARLIBS=../libqemu_common.a libqemu.a $(HWLIB)
 
-$(QEMU_PROG): ARLIBS += $(DEPLIBS)
-$(QEMU_PROG): $(DEPLIBS)
-
 endif # CONFIG_SOFTMMU
 
 $(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(ARLIBS)
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: initialize idt on all processors

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/x86/cstart64.S b/kvm/user/test/x86/cstart64.S
index 278465b..a55ad50 100644
--- a/kvm/user/test/x86/cstart64.S
+++ b/kvm/user/test/x86/cstart64.S
@@ -1,6 +1,7 @@
 
 #include apic-defs.h
 
+.globl boot_idt
 boot_idt = 0
 
 ipi_vector = 0x20
@@ -160,7 +161,12 @@ start64:
mov %eax, %edi
call exit
 
+idt_descr:
+   .word 16 * 256 - 1
+   .quad boot_idt
+
 load_tss:
+   lidtq idt_descr
mov $0, %eax
mov %ax, %ss
mov $(APIC_DEFAULT_PHYS_BASE + APIC_ID), %eax
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] gdbstub: x86: Switch 64/32 bit registers dynamically

2009-09-21 Thread Avi Kivity
From: Jan Kiszka jan.kis...@siemens.com

Commit 56aebc891674cd2d07b3f64183415697be200084 changed gdbstub in way
that debugging 32 or 16-bit guest code is no longer possible with qemu
for x86_64 guest CPUs. Since that commit, qemu only provides registers
sets for 64-bit, forcing current and foreseeable gdb to also switch its
architecture to 64-bit. And this breaks if the inferior is 32 or 16 bit.

No question, this is a gdb issue. But, as it was confirmed in several
discusssions with gdb people, it is a non-trivial thing to fix. So until
qemu finds a gdb version attach with a rework x86 support, we have to
work around it by switching the register layout as the guest switches
its execution mode between 16/32 and 64 bit.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/gdbstub.c b/gdbstub.c
index c9304cd..a33aba0 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -506,8 +506,9 @@ static const int gpr_map[16] = {
 8, 9, 10, 11, 12, 13, 14, 15
 };
 #else
-static const int gpr_map[8] = {0, 1, 2, 3, 4, 5, 6, 7};
+#define gpr_map gpr_map32
 #endif
+static const int gpr_map32[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
 
 #define NUM_CORE_REGS (CPU_NB_REGS * 2 + 25)
 
@@ -521,7 +522,11 @@ static const int gpr_map[8] = {0, 1, 2, 3, 4, 5, 6, 7};
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)
 {
 if (n  CPU_NB_REGS) {
-GET_REGL(env-regs[gpr_map[n]]);
+if (TARGET_LONG_BITS == 64  env-hflags  HF_CS64_MASK) {
+GET_REG64(env-regs[gpr_map[n]]);
+} else if (n  CPU_NB_REGS32) {
+GET_REG32(env-regs[gpr_map32[n]]);
+}
 } else if (n = IDX_FP_REGS  n  IDX_FP_REGS + 8) {
 #ifdef USE_X86LDOUBLE
 /* FIXME: byteswap float values - after fixing fpregs layout. */
@@ -532,12 +537,20 @@ static int cpu_gdb_read_register(CPUState *env, uint8_t 
*mem_buf, int n)
 return 10;
 } else if (n = IDX_XMM_REGS  n  IDX_XMM_REGS + CPU_NB_REGS) {
 n -= IDX_XMM_REGS;
-stq_p(mem_buf, env-xmm_regs[n].XMM_Q(0));
-stq_p(mem_buf + 8, env-xmm_regs[n].XMM_Q(1));
-return 16;
+if (n  CPU_NB_REGS32 ||
+(TARGET_LONG_BITS == 64  env-hflags  HF_CS64_MASK)) {
+stq_p(mem_buf, env-xmm_regs[n].XMM_Q(0));
+stq_p(mem_buf + 8, env-xmm_regs[n].XMM_Q(1));
+return 16;
+}
 } else {
 switch (n) {
-case IDX_IP_REG:GET_REGL(env-eip);
+case IDX_IP_REG:
+if (TARGET_LONG_BITS == 64  env-hflags  HF_CS64_MASK) {
+GET_REG64(env-eip);
+} else {
+GET_REG32(env-eip);
+}
 case IDX_FLAGS_REG: GET_REG32(env-eflags);
 
 case IDX_SEG_REGS: GET_REG32(env-segs[R_CS].selector);
@@ -593,8 +606,15 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t 
*mem_buf, int n)
 uint32_t tmp;
 
 if (n  CPU_NB_REGS) {
-env-regs[gpr_map[n]] = ldtul_p(mem_buf);
-return sizeof(target_ulong);
+if (TARGET_LONG_BITS == 64  env-hflags  HF_CS64_MASK) {
+env-regs[gpr_map[n]] = ldtul_p(mem_buf);
+return sizeof(target_ulong);
+} else if (n  CPU_NB_REGS32) {
+n = gpr_map32[n];
+env-regs[n] = ~0xUL;
+env-regs[n] |= (uint32_t)ldl_p(mem_buf);
+return 4;
+}
 } else if (n = IDX_FP_REGS  n  IDX_FP_REGS + 8) {
 #ifdef USE_X86LDOUBLE
 /* FIXME: byteswap float values - after fixing fpregs layout. */
@@ -603,14 +623,23 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t 
*mem_buf, int n)
 return 10;
 } else if (n = IDX_XMM_REGS  n  IDX_XMM_REGS + CPU_NB_REGS) {
 n -= IDX_XMM_REGS;
-env-xmm_regs[n].XMM_Q(0) = ldq_p(mem_buf);
-env-xmm_regs[n].XMM_Q(1) = ldq_p(mem_buf + 8);
-return 16;
+if (n  CPU_NB_REGS32 ||
+(TARGET_LONG_BITS == 64  env-hflags  HF_CS64_MASK)) {
+env-xmm_regs[n].XMM_Q(0) = ldq_p(mem_buf);
+env-xmm_regs[n].XMM_Q(1) = ldq_p(mem_buf + 8);
+return 16;
+}
 } else {
 switch (n) {
 case IDX_IP_REG:
-env-eip = ldtul_p(mem_buf);
-return sizeof(target_ulong);
+if (TARGET_LONG_BITS == 64  env-hflags  HF_CS64_MASK) {
+env-eip = ldq_p(mem_buf);
+return 8;
+} else {
+env-eip = ~0xUL;
+env-eip |= (uint32_t)ldl_p(mem_buf);
+return 4;
+}
 case IDX_FLAGS_REG:
 env-eflags = ldl_p(mem_buf);
 return 4;
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index b9a6392..4506d73 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -555,10 +555,13 @@ typedef union {
 #endif
 #define MMX_Q(n) q
 
+#define CPU_NB_REGS64 16
+#define CPU_NB_REGS32 8
+
 #ifdef TARGET_X86_64
-#define CPU_NB_REGS 16
+#define 

[COMMIT master] qemu-kvm: fix -daemonize

2009-09-21 Thread Avi Kivity
From: Marcelo Tosatti mtosa...@redhat.com

Move kvm_init after fork.

Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/vl.c b/vl.c
index 888d481..88bd3eb 100644
--- a/vl.c
+++ b/vl.c
@@ -5533,20 +5533,6 @@ int main(int argc, char **argv, char **envp)
 }
 }
 
-if (kvm_enabled()) {
-int ret;
-
-ret = kvm_init(smp_cpus);
-if (ret  0) {
-#if defined(KVM_UPSTREAM) || defined(NO_CPU_EMULATION)
-fprintf(stderr, failed to initialize KVM\n);
-exit(1);
-#endif
-fprintf(stderr, Could not initialize KVM, will disable KVM 
support\n);
-kvm_allowed = 0;
-}
-}
-
 /* If no data_dir is specified then try to find it relative to the
executable path.  */
 if (!data_dir) {
@@ -5636,6 +5622,20 @@ int main(int argc, char **argv, char **envp)
 }
 #endif
 
+if (kvm_enabled()) {
+int ret;
+
+ret = kvm_init(smp_cpus);
+if (ret  0) {
+#if defined(KVM_UPSTREAM) || defined(NO_CPU_EMULATION)
+fprintf(stderr, failed to initialize KVM\n);
+exit(1);
+#endif
+fprintf(stderr, Could not initialize KVM, will disable KVM 
support\n);
+kvm_allowed = 0;
+}
+}
+
 if (qemu_init_main_loop()) {
 fprintf(stderr, qemu_init_main_loop failed\n);
 exit(1);
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: avoid deleting intermediate .o files

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

If make doesn't see an intermediate file mentioned explicitly, it
deletes it after making the target.  This silly behaviour causes
needless rebuilds.

Add all intermediates as explicit dependncies to prevent this
behaviour.

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/config-x86-common.mak b/kvm/user/config-x86-common.mak
index 9d6d281..3f279ed 100644
--- a/kvm/user/config-x86-common.mak
+++ b/kvm/user/config-x86-common.mak
@@ -48,7 +48,8 @@ $(TEST_DIR)/test32.flat: $(TEST_DIR)/test32.o
 
 $(TEST_DIR)/smptest.flat: $(cstart.o) $(TEST_DIR)/smptest.o
  
-$(TEST_DIR)/emulator.flat: $(cstart.o) $(TEST_DIR)/vm.o $(TEST_DIR)/print.o
+$(TEST_DIR)/emulator.flat: $(cstart.o) $(TEST_DIR)/emulator.o \
+  $(TEST_DIR)/vm.o $(TEST_DIR)/print.o
 
 $(TEST_DIR)/port80.flat: $(cstart.o) $(TEST_DIR)/port80.o
 
@@ -62,6 +63,12 @@ $(TEST_DIR)/realmode.flat: $(TEST_DIR)/realmode.o
 
 $(TEST_DIR)/realmode.o: bits = 32
 
+$(TEST_DIR)/memtest1.flat: $(TEST_DIR)/memtest1.o
+
+$(TEST_DIR)/stringio.flat: $(TEST_DIR)/stringio.o
+
+$(TEST_DIR)/simple.flat: $(TEST_DIR)/simple.o
+
 $(TEST_DIR)/msr.flat: $(cstart.o) $(TEST_DIR)/msr.o
 
 arch_clean:
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Introduce libs_softmmu to device assignment code

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/Makefile.target b/Makefile.target
index 5fad812..b2a2e45 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -217,7 +217,6 @@ obj-i386-y += i8254-kvm.o
 endif
 ifeq ($(USE_KVM_DEVICE_ASSIGNMENT), 1)
 obj-i386-y += device-assignment.o
-LIBS+=-lpci
 endif
 
 # Hardware support
@@ -228,7 +227,6 @@ obj-ia64-y += usb-uhci.o
 
 ifeq ($(USE_KVM_DEVICE_ASSIGNMENT), 1)
 obj-ia64-y += device-assignment.o
-LIBS+=-lpci
 endif
 
 # shared objects
diff --git a/configure b/configure
index 5ae8443..97b0012 100755
--- a/configure
+++ b/configure
@@ -964,7 +964,7 @@ cat  $TMPC  EOF
 int main(void) { return 0; }
 EOF
 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC 2/dev/null ; then
-:
+libs_softmmu=-lpci $libs_softmmu
 else
 echo
 echo Error: libpci check failed
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Use kvm_cpu_synchronize_state() instead of kvm_arch_(save|load)_regs()

2009-09-21 Thread Avi Kivity
From: Gleb Natapov g...@redhat.com

Signed-off-by: Gleb Natapov g...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index ee678df..6e5bcc5 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1671,10 +1671,9 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, 
uint32_t function,
 
 void kvm_arch_process_irqchip_events(CPUState *env)
 {
-kvm_arch_save_regs(env);
+kvm_cpu_synchronize_state(env);
 if (env-interrupt_request  CPU_INTERRUPT_INIT)
 do_cpu_init(env);
 if (env-interrupt_request  CPU_INTERRUPT_SIPI)
 do_cpu_sipi(env);
-kvm_arch_load_regs(env);
 }
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] test: add apic_id() accessor

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

apic and x2apic have different formats for the ID register, so we need an
accessor for it.

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/user/test/lib/x86/apic.c b/kvm/user/test/lib/x86/apic.c
index 25517ef..16e51bc 100644
--- a/kvm/user/test/lib/x86/apic.c
+++ b/kvm/user/test/lib/x86/apic.c
@@ -14,6 +14,7 @@ struct apic_ops {
 u32 (*reg_read)(unsigned reg);
 void (*reg_write)(unsigned reg, u32 val);
 void (*icr_write)(u32 val, u32 dest);
+u32 (*id)(void);
 };
 
 static void outb(unsigned char data, unsigned short port)
@@ -39,10 +40,16 @@ static void xapic_icr_write(u32 val, u32 dest)
 xapic_write(APIC_ICR, val);
 }
 
+static uint32_t xapic_id(void)
+{
+return xapic_read(APIC_ID)  24;
+}
+
 static const struct apic_ops xapic_ops = {
 .reg_read = xapic_read,
 .reg_write = xapic_write,
 .icr_write = xapic_icr_write,
+.id = xapic_id,
 };
 
 static const struct apic_ops *apic_ops = xapic_ops;
@@ -66,10 +73,16 @@ static void x2apic_icr_write(u32 val, u32 dest)
   c(APIC_BASE_MSR + APIC_ICR/16));
 }
 
+static uint32_t x2apic_id(void)
+{
+return xapic_read(APIC_ID);
+}
+
 static const struct apic_ops x2apic_ops = {
 .reg_read = x2apic_read,
 .reg_write = x2apic_write,
 .icr_write = x2apic_icr_write,
+.id = x2apic_id,
 };
 
 u32 apic_read(unsigned reg)
@@ -87,6 +100,11 @@ void apic_icr_write(u32 val, u32 dest)
 apic_ops-icr_write(val, dest);
 }
 
+uint32_t apic_id(void)
+{
+return apic_ops-id();
+}
+
 #define MSR_APIC_BASE 0x001b
 
 int enable_x2apic(void)
diff --git a/kvm/user/test/lib/x86/apic.h b/kvm/user/test/lib/x86/apic.h
index 0115ba4..e325e9a 100644
--- a/kvm/user/test/lib/x86/apic.h
+++ b/kvm/user/test/lib/x86/apic.h
@@ -27,6 +27,7 @@ void enable_apic(void);
 uint32_t apic_read(unsigned reg);
 void apic_write(unsigned reg, uint32_t val);
 void apic_icr_write(uint32_t val, uint32_t dest);
+uint32_t apic_id(void);
 
 int enable_x2apic(void);
 
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] KVM temp hack not needed anymore

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/configure b/configure
index 911cac6..5ae8443 100755
--- a/configure
+++ b/configure
@@ -2076,11 +2076,6 @@ bsd)
 ;;
 esac
 
-# this is a temp hack needed for kvm
-if test $kvm = yes ; then
-echo KVM_CFLAGS=$kvm_cflags  $config_host_mak
-fi
-
 echo KVM_KMOD=$kvm_kmod  $config_host_mak
 
 tools=
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Test for libpci, not only for header

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/configure b/configure
index dcb4625..2d13f6d 100755
--- a/configure
+++ b/configure
@@ -961,9 +961,9 @@ cat  $TMPC  EOF
 #ifndef PCI_VENDOR_ID
 #error NO LIBPCI
 #endif
-int main(void) { return 0; }
+int main(void) { struct pci_access a; pci_init(a); return 0; }
 EOF
-if compile_prog   ; then
+if compile_prog  -lpci ; then
 libs_softmmu=-lpci $libs_softmmu
 else
 echo
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Use configure way of enabling kvm

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/configure b/configure
index edf46ee..7e51644 100755
--- a/configure
+++ b/configure
@@ -362,19 +362,14 @@ AIX)
   usb=linux
   if [ $cpu = i386 -o $cpu = x86_64 ] ; then
 audio_possible_drivers=$audio_possible_drivers fmod
-kvm=yes
   fi
   if [ $cpu = ia64 ] ; then
- kvm=yes
  xen=no
  target_list=ia64-softmmu
  cpu_emulation=no
  gdbstub=no
  slirp=no
   fi
-  if [ $cpu = powerpc ]; then
-  kvm=yes
-  fi
 ;;
 esac
 
@@ -926,7 +921,7 @@ esac
 
 kvm_cflags=
 
-if test $kvm = yes ; then
+if test $kvm != no ; then
 
 kvm_cflags=-I$source_path/kvm/include
 kvm_cflags=$kvm_cflags -I$source_path/kvm/include/$kvm_arch
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] update qemu-ifup for modern ip route output

2009-09-21 Thread Avi Kivity
From: Dustin Kirkland kirkl...@canonical.com

update qemu-ifup for modern ip route output

The output from the /sbin/ip utility has changed, adding two
more columns, which breaks the qemu-ifup script, as it was
depending on the last column being the interface name.

Change this from $NF to $5.

https://bugs.edge.launchpad.net/ubuntu/+source/qemu-kvm/+bug/430652

Signed-off-by: Dustin Kirkland kirkl...@canonical.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/kvm/scripts/qemu-ifup b/kvm/scripts/qemu-ifup
index 3bf8801..284b176 100755
--- a/kvm/scripts/qemu-ifup
+++ b/kvm/scripts/qemu-ifup
@@ -1,5 +1,5 @@
 #!/bin/sh
 
-switch=$(/sbin/ip route list | awk '/^default / { print $NF }')
+switch=$(/sbin/ip route list | awk '/^default / { print $5 }')
 /sbin/ifconfig $1 0.0.0.0 up
 /usr/sbin/brctl addif ${switch} $1
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Print kvm options values as everything else

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/configure b/configure
index 7e51644..911cac6 100755
--- a/configure
+++ b/configure
@@ -2052,6 +2052,9 @@ fi
 if test $need_offsetof = yes ; then
   echo CONFIG_NEED_OFFSETOF=y  $config_host_mak
 fi
+if test $cpu_emulation = no; then
+  echo NO_CPU_EMULATION=1  $config_host_mak
+fi
 
 # XXX: suppress that
 if [ $bsd = yes ] ; then
@@ -2224,28 +2227,6 @@ interp_prefix1=`echo $interp_prefix | sed 
s/%M/$target_arch2/g`
 echo CONFIG_QEMU_PREFIX=\$interp_prefix1\  $config_mak
 gdb_xml_files=
 
-disable_cpu_emulation() {
-  if test $cpu_emulation = no; then
-echo #define NO_CPU_EMULATION 1  $config_host_h
-echo NO_CPU_EMULATION=1  $config_host_mak
-  fi
-}
-
-configure_kvm() {
-  if test $kvm = yes -a $target_softmmu = yes -a \
-  \( $cpu = i386 -o $cpu = x86_64 -o $cpu = ia64 -o $cpu 
= powerpc \); then
-echo CONFIG_KVM=y  $config_mak
-echo KVM_CFLAGS=$kvm_cflags  $config_mak
-if test $kvm_cap_pit = yes ; then
-   echo USE_KVM_PIT=1  $config_mak
-fi
-if test $kvm_cap_device_assignment = yes ; then
-   echo USE_KVM_DEVICE_ASSIGNMENT=1  $config_mak
-fi
-disable_cpu_emulation
-  fi
-}
-
 TARGET_ARCH=$target_arch2
 TARGET_BASE_ARCH=
 TARGET_ABI_DIR=
@@ -2388,7 +2369,12 @@ case $target_arch2 in
   \( $target_arch2 = i386   -a $cpu = x86_64 \) \) ; then
   echo CONFIG_KVM=y  $config_mak
   echo KVM_CFLAGS=$kvm_cflags  $config_mak
-  configure_kvm
+  if test $kvm_cap_pit = yes ; then
+echo USE_KVM_PIT=1  $config_mak
+  fi
+  if test $kvm_cap_device_assignment = yes ; then
+echo USE_KVM_DEVICE_ASSIGNMENT=1  $config_mak
+  fi
 fi
 esac
 echo TARGET_PHYS_ADDR_BITS=$target_phys_bits  $config_mak
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Bring ia64 to current arch selection code

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/configure b/configure
index fb28e14..edf46ee 100755
--- a/configure
+++ b/configure
@@ -2264,9 +2264,6 @@ case $target_arch2 in
 target_phys_bits=64
   ;;
   ia64)
-echo TARGET_ARCH=ia64  $config_host_mak
-echo #define TARGET_ARCH \ia64\  $config_host_h
-echo #define TARGET_IA64 1  $config_host_h
 target_phys_bits=64
   ;;
   alpha)
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Rename USE_KVM_* to CONFIG_KVM_*

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Once there, simplify Makefile.target with new syntax

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/Makefile.target b/Makefile.target
index b2a2e45..d2444ac 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -212,22 +212,16 @@ obj-i386-y += extboot.o
 obj-i386-y += piix4.o
 obj-i386-y += ne2000-isa.o
 obj-i386-y += testdev.o
-ifeq ($(USE_KVM_PIT), 1)
-obj-i386-y += i8254-kvm.o
-endif
-ifeq ($(USE_KVM_DEVICE_ASSIGNMENT), 1)
-obj-i386-y += device-assignment.o
-endif
+
+obj-i386-$(CONFIG_KVM_PIT) += i8254-kvm.o
+obj-i386-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += device-assignment.o
 
 # Hardware support
 obj-ia64-y += ide.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
 obj-ia64-y += fdc.o mc146818rtc.o serial.o i8259.o ipf.o
 obj-ia64-y += cirrus_vga.o parallel.o acpi.o piix_pci.o
 obj-ia64-y += usb-uhci.o
-
-ifeq ($(USE_KVM_DEVICE_ASSIGNMENT), 1)
-obj-ia64-y += device-assignment.o
-endif
+obj-ia64-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += device-assignment.o
 
 # shared objects
 obj-ppc-y = ppc.o ide/core.o ide/isa.o ide/pci.o ide/macio.o
diff --git a/configure b/configure
index 2d13f6d..d8b2b7b 100755
--- a/configure
+++ b/configure
@@ -2365,10 +2365,10 @@ case $target_arch2 in
   echo CONFIG_KVM=y  $config_mak
   echo KVM_CFLAGS=$kvm_cflags  $config_mak
   if test $kvm_cap_pit = yes ; then
-echo USE_KVM_PIT=1  $config_mak
+echo CONFIG_KVM_PIT=y  $config_mak
   fi
   if test $kvm_cap_device_assignment = yes ; then
-echo USE_KVM_DEVICE_ASSIGNMENT=1  $config_mak
+echo CONFIG_KVM_DEVICE_ASSIGNMENT=y  $config_mak
   fi
 fi
 esac
diff --git a/create_config b/create_config
index 8d265d1..5bc8fb6 100755
--- a/create_config
+++ b/create_config
@@ -85,9 +85,6 @@ case $line in
 value=${line#*=}
 echo #define $name $value
 ;;
- USE_KVM_*)
-echo #define $(echo $line | sed 's/=/ /')
-;;
 esac
 
 done # read
diff --git a/hw/ipf.c b/hw/ipf.c
index 04b7b2c..21cff72 100644
--- a/hw/ipf.c
+++ b/hw/ipf.c
@@ -636,10 +636,10 @@ static void ipf_init1(ram_addr_t ram_size,
}
 }
 
-#ifdef USE_KVM_DEVICE_ASSIGNMENT
+#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
 if (kvm_enabled())
add_assigned_devices(pci_bus, assigned_devices, assigned_devices_index);
-#endif /* USE_KVM_DEVICE_ASSIGNMENT */
+#endif /* CONFIG_KVM_DEVICE_ASSIGNMENT */
 
 }
 
diff --git a/hw/pc.c b/hw/pc.c
index 5f892c7..7e2a502 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1344,7 +1344,7 @@ static void pc_init1(ram_addr_t ram_size,
 isa_irq_state-ioapic = ioapic_init();
 ioapic_irq_hack = isa_irq;
 }
-#ifdef USE_KVM_PIT
+#ifdef CONFIG_KVM_PIT
 if (kvm_enabled()  qemu_kvm_pit_in_kernel())
pit = kvm_pit_init(0x40, isa_reserve_irq(0));
 else
@@ -1468,12 +1468,12 @@ static void pc_init1(ram_addr_t ram_size,
 }
 }
 
-#ifdef USE_KVM_DEVICE_ASSIGNMENT
+#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
 if (kvm_enabled()) {
 add_assigned_devices(pci_bus, assigned_devices, 
assigned_devices_index);
 assigned_dev_load_option_roms(pci_option_rom_offset);
 }
-#endif /* USE_KVM_DEVICE_ASSIGNMENT */
+#endif /* CONFIG_KVM_DEVICE_ASSIGNMENT */
 }
 
 static void pc_init_pci(ram_addr_t ram_size,
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index b8ea9ae..eab0756 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -155,7 +155,7 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
 return dev;
 }
 
-#ifdef USE_KVM_DEVICE_ASSIGNMENT
+#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
 static PCIDevice *qemu_pci_hot_assign_device(Monitor *mon,
  const char *devaddr,
  const char *opts)
@@ -192,7 +192,7 @@ static void qemu_pci_hot_deassign_device(Monitor *mon, 
AssignedDevInfo *adev)
(\%s\) from guest\n,
adev-bus, adev-dev, adev-func, adev-name);
 }
-#endif /* USE_KVM_DEVICE_ASSIGNMENT */
+#endif /* CONFIG_KVM_DEVICE_ASSIGNMENT */
 
 void pci_device_hot_add(Monitor *mon, const QDict *qdict)
 {
@@ -217,10 +217,10 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict)
 dev = qemu_pci_hot_add_nic(mon, pci_addr, opts);
 else if (strcmp(type, storage) == 0)
 dev = qemu_pci_hot_add_storage(mon, pci_addr, opts);
-#ifdef USE_KVM_DEVICE_ASSIGNMENT
+#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
 else if (strcmp(type, host) == 0)
 dev = qemu_pci_hot_assign_device(mon, pci_addr, opts);
-#endif /* USE_KVM_DEVICE_ASSIGNMENT */
+#endif /* CONFIG_KVM_DEVICE_ASSIGNMENT */
 else
 monitor_printf(mon, invalid type: %s\n, type);
 
@@ -274,7 +274,7 @@ void pci_device_hot_remove_success(int pcibus, int slot)
 {
 PCIDevice *d = pci_find_device(pcibus, slot, 0);
 int class_code;
-#ifdef USE_KVM_DEVICE_ASSIGNMENT
+#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
 AssignedDevInfo *adev;
 #endif
 
@@ -283,13 

[COMMIT master] Use compile_prog function in thee missing compilations

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/configure b/configure
index 97b0012..dcb4625 100755
--- a/configure
+++ b/configure
@@ -936,7 +936,7 @@ cat  $TMPC EOF
 #endif
 int main(void) { return 0; }
 EOF
-if $cc $ARCH_CFLAGS $CFLAGS $kvm_cflags -o $TMPE ${OS_CFLAGS} $TMPC 2 
/dev/null ; then
+if compile_prog $kvm_cflags ; then
kvm_cap_pit=yes
 fi
 
@@ -949,7 +949,7 @@ cat  $TMPC EOF
 #endif
 int main(void) { return 0; }
 EOF
-if $cc $ARCH_CFLAGS $CFLAGS $kvm_cflags -o $TMPE ${OS_CFLAGS} $TMPC 2 
/dev/null ; then
+if compile_prog $kvm_cflags  ; then
kvm_cap_device_assignment=yes
 fi
 fi
@@ -963,7 +963,7 @@ cat  $TMPC  EOF
 #endif
 int main(void) { return 0; }
 EOF
-if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC 2/dev/null ; then
+if compile_prog   ; then
 libs_softmmu=-lpci $libs_softmmu
 else
 echo
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Move kvm specific tests after main kvm test

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/configure b/configure
index d8b2b7b..dc0d677 100755
--- a/configure
+++ b/configure
@@ -905,76 +905,6 @@ EOF
 fi
 
 ##
-# KVM probe
-
-case $cpu in
-i386 | x86_64)
-   kvm_arch=x86
-   ;;
-ppc)
-kvm_arch=powerpc
-;;
-*)
-   kvm_arch=$cpu
-   ;;
-esac
-
-kvm_cflags=
-
-if test $kvm != no ; then
-
-kvm_cflags=-I$source_path/kvm/include
-kvm_cflags=$kvm_cflags -I$source_path/kvm/include/$kvm_arch
-kvm_cflags=$kvm_cflags -idirafter $source_path/compat
-
-# test for KVM_CAP_PIT
-
-cat  $TMPC EOF
-#include linux/kvm.h
-#ifndef KVM_CAP_PIT
-#error kvm no pit capability
-#endif
-int main(void) { return 0; }
-EOF
-if compile_prog $kvm_cflags ; then
-   kvm_cap_pit=yes
-fi
-
-# test for KVM_CAP_DEVICE_ASSIGNMENT
-
-cat  $TMPC EOF
-#include linux/kvm.h
-#ifndef KVM_CAP_DEVICE_ASSIGNMENT
-#error kvm no device assignment capability
-#endif
-int main(void) { return 0; }
-EOF
-if compile_prog $kvm_cflags  ; then
-   kvm_cap_device_assignment=yes
-fi
-fi
-
-# libpci probe for kvm_cap_device_assignment
-if test $kvm_cap_device_assignment = yes ; then
-cat  $TMPC  EOF
-#include pci/pci.h
-#ifndef PCI_VENDOR_ID
-#error NO LIBPCI
-#endif
-int main(void) { struct pci_access a; pci_init(a); return 0; }
-EOF
-if compile_prog  -lpci ; then
-libs_softmmu=-lpci $libs_softmmu
-else
-echo
-echo Error: libpci check failed
-echo Disable KVM Device Assignment capability.
-echo
-kvm_cap_device_assignment=no
-fi
-fi
-
-##
 # zlib check
 
 cat  $TMPC  EOF
@@ -1372,7 +1302,23 @@ fi
 ##
 # kvm probe
 if test $kvm != no ; then
-cat  $TMPC EOF
+  case $cpu in
+  i386 | x86_64)
+kvm_arch=x86
+;;
+  ppc)
+kvm_arch=powerpc
+;;
+  *)
+kvm_arch=$cpu
+;;
+  esac
+
+  kvm_cflags=-I$source_path/kvm/include
+  kvm_cflags=$kvm_cflags -I$source_path/kvm/include/$kvm_arch
+  kvm_cflags=$kvm_cflags -idirafter $source_path/compat
+
+  cat  $TMPC EOF
 #include linux/kvm.h
 #if !defined(KVM_API_VERSION) || KVM_API_VERSION  12 || KVM_API_VERSION  12
 #error Invalid KVM version
@@ -1410,6 +1356,58 @@ EOF
 fi
 
 ##
+# test for KVM_CAP_PIT
+
+if test $kvm != no ; then
+  cat  $TMPC EOF
+#include linux/kvm.h
+#ifndef KVM_CAP_PIT
+#error kvm no pit capability
+#endif
+int main(void) { return 0; }
+EOF
+  if compile_prog $kvm_cflags ; then
+kvm_cap_pit=yes
+  fi
+fi
+
+##
+# test for KVM_CAP_DEVICE_ASSIGNMENT
+if test $kvm != no ; then
+  cat  $TMPC EOF
+#include linux/kvm.h
+#ifndef KVM_CAP_DEVICE_ASSIGNMENT
+#error kvm no device assignment capability
+#endif
+int main(void) { return 0; }
+EOF
+  if compile_prog $kvm_cflags  ; then
+kvm_cap_device_assignment=yes
+  fi
+fi
+
+##
+# libpci probe for kvm_cap_device_assignment
+if test $kvm_cap_device_assignment = yes ; then
+  cat  $TMPC  EOF
+#include pci/pci.h
+#ifndef PCI_VENDOR_ID
+#error NO LIBPCI
+#endif
+int main(void) { struct pci_access a; pci_init(a); return 0; }
+EOF
+  if compile_prog  -lpci ; then
+libs_softmmu=-lpci $libs_softmmu
+  else
+echo
+echo Error: libpci check failed
+echo Disable KVM Device Assignment capability.
+echo
+kvm_cap_device_assignment=no
+  fi
+fi
+
+##
 # pthread probe
 PTHREADLIBS_LIST=-lpthread -lpthreadGC2
 
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] vga: move back dirty_log functions to vga.c

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Fixes build problems.

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/hw/vga-pci.c b/hw/vga-pci.c
index c49858c..9bb2d81 100644
--- a/hw/vga-pci.c
+++ b/hw/vga-pci.c
@@ -28,7 +28,6 @@
 #include vga_int.h
 #include pixel_ops.h
 #include qemu-timer.h
-#include kvm.h
 
 typedef struct PCIVGAState {
 PCIDevice dev;
@@ -59,48 +58,6 @@ static int pci_vga_load(QEMUFile *f, void *opaque, int 
version_id)
 return vga_common_load(f, s-vga, version_id);
 }
 
-static int s1, s2;
-
-static void mark_dirty(target_phys_addr_t start, target_phys_addr_t len)
-{
-target_phys_addr_t end = start + len;
-
-while (start  end) {
-cpu_physical_memory_set_dirty(cpu_get_physical_page_desc(start));
-start += TARGET_PAGE_SIZE;
-}
-}
-
-void vga_dirty_log_start(VGACommonState *s)
-{
-if (kvm_enabled()  s-map_addr)
-if (!s1) {
-kvm_log_start(s-map_addr, s-map_end - s-map_addr);
-mark_dirty(s-map_addr, s-map_end - s-map_addr);
-s1 = 1;
-}
-if (kvm_enabled()  s-lfb_vram_mapped) {
-if (!s2) {
-kvm_log_start(isa_mem_base + 0xa, 0x8000);
-kvm_log_start(isa_mem_base + 0xa8000, 0x8000);
-mark_dirty(isa_mem_base + 0xa, 0x1);
-}
-s2 = 1;
-}
-}
-
-void vga_dirty_log_stop(VGACommonState *s)
-{
-if (kvm_enabled()  s-map_addr  s1)
-kvm_log_stop(s-map_addr, s-map_end - s-map_addr);
-
-if (kvm_enabled()  s-lfb_vram_mapped  s2) {
-kvm_log_stop(isa_mem_base + 0xa, 0x8000);
-kvm_log_stop(isa_mem_base + 0xa8000, 0x8000);
-}
-s1 = s2 = 0;
-}
-
 static void vga_map(PCIDevice *pci_dev, int region_num,
 uint32_t addr, uint32_t size, int type)
 {
diff --git a/hw/vga.c b/hw/vga.c
index df4c063..29a9f81 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -28,6 +28,7 @@
 #include vga_int.h
 #include pixel_ops.h
 #include qemu-timer.h
+#include kvm.h
 
 //#define DEBUG_VGA
 //#define DEBUG_VGA_MEM
@@ -1579,6 +1580,48 @@ static void vga_sync_dirty_bitmap(VGACommonState *s)
 vga_dirty_log_start(s);
 }
 
+static int s1, s2;
+
+static void mark_dirty(target_phys_addr_t start, target_phys_addr_t len)
+{
+target_phys_addr_t end = start + len;
+
+while (start  end) {
+cpu_physical_memory_set_dirty(cpu_get_physical_page_desc(start));
+start += TARGET_PAGE_SIZE;
+}
+}
+
+void vga_dirty_log_start(VGACommonState *s)
+{
+if (kvm_enabled()  s-map_addr)
+if (!s1) {
+kvm_log_start(s-map_addr, s-map_end - s-map_addr);
+mark_dirty(s-map_addr, s-map_end - s-map_addr);
+s1 = 1;
+}
+if (kvm_enabled()  s-lfb_vram_mapped) {
+if (!s2) {
+kvm_log_start(isa_mem_base + 0xa, 0x8000);
+kvm_log_start(isa_mem_base + 0xa8000, 0x8000);
+mark_dirty(isa_mem_base + 0xa, 0x1);
+}
+s2 = 1;
+}
+}
+
+void vga_dirty_log_stop(VGACommonState *s)
+{
+if (kvm_enabled()  s-map_addr  s1)
+kvm_log_stop(s-map_addr, s-map_end - s-map_addr);
+
+if (kvm_enabled()  s-lfb_vram_mapped  s2) {
+kvm_log_stop(isa_mem_base + 0xa, 0x8000);
+kvm_log_stop(isa_mem_base + 0xa8000, 0x8000);
+}
+s1 = s2 = 0;
+}
+
 /*
  * graphic modes
  */
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Remove build-targets-* rules that are always empty

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/Makefile b/Makefile
index 88b39bd..1e09953 100644
--- a/Makefile
+++ b/Makefile
@@ -386,10 +386,3 @@ tarbin:
 
 # Include automatically generated dependency files
 -include $(wildcard *.d audio/*.d slirp/*.d block/*.d)
-
-build-targets-i386 = $(build-targets-x86)
-build-targets-x86_64 = $(build-targets-x86)
-build-targets-x86  =
-build-targets-ia64 =
-
-all: $(build-targets-$(ARCH))
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Get CONFIG_CPU_EMULATION back to life

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Code compile with --disable-cpu-emulation, and that don't compile
tcg.  This is the minimal set of changes to get it working

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/Makefile.target b/Makefile.target
index d2444ac..e2965b6 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -33,8 +33,10 @@ all: $(PROGS)
 
 #
 # cpu emulator library
-libobj-y = exec.o translate-all.o cpu-exec.o translate.o host-utils.o
-libobj-y += tcg/tcg.o tcg/tcg-runtime.o
+libobj-y = exec.o cpu-exec.o host-utils.o
+libobj-$(CONFIG_NO_CPU_EMULATION) += fake-exec.o
+libobj-$(CONFIG_CPU_EMULATION) += translate-all.o translate.o
+libobj-$(CONFIG_CPU_EMULATION) += tcg/tcg.o tcg/tcg-runtime.o
 libobj-$(CONFIG_SOFTFLOAT) += fpu/softfloat.o
 libobj-$(CONFIG_NOSOFTFLOAT) += fpu/softfloat-native.o
 libobj-y += op_helper.o helper.o
diff --git a/configure b/configure
index f8d7402..6c6cb13 100755
--- a/configure
+++ b/configure
@@ -2078,8 +2078,10 @@ fi
 if test $need_offsetof = yes ; then
   echo CONFIG_NEED_OFFSETOF=y  $config_host_mak
 fi
-if test $cpu_emulation = no; then
-  echo NO_CPU_EMULATION=1  $config_host_mak
+if test $cpu_emulation = yes; then
+  echo CONFIG_CPU_EMULATION=y  $config_host_mak
+else
+  echo CONFIG_NO_CPU_EMULATION=y  $config_host_mak
 fi
 
 # XXX: suppress that
diff --git a/exec.c b/exec.c
index dd8881c..aff9ec8 100644
--- a/exec.c
+++ b/exec.c
@@ -3795,7 +3795,9 @@ void dump_exec_info(FILE *f,
 cpu_fprintf(f, TB flush count  %d\n, tb_flush_count);
 cpu_fprintf(f, TB invalidate count %d\n, tb_phys_invalidate_count);
 cpu_fprintf(f, TLB flush count %d\n, tlb_flush_count);
+#ifdef CONFIG_PROFILER
 tcg_dump_info(f, cpu_fprintf);
+#endif
 }
 
 #if !defined(CONFIG_USER_ONLY)
diff --git a/target-i386/fake-exec.c b/target-i386/fake-exec.c
index 737286d..dfa202d 100644
--- a/target-i386/fake-exec.c
+++ b/target-i386/fake-exec.c
@@ -45,10 +45,6 @@ int cpu_x86_gen_code(CPUState *env, TranslationBlock *tb, 
int *gen_code_size_ptr
 return 0;
 }
 
-void flush_icache_range(unsigned long start, unsigned long stop)
-{
-}
-
 void optimize_flags_init(void)
 {
 }
diff --git a/vl.c b/vl.c
index 88bd3eb..5d4e18f 100644
--- a/vl.c
+++ b/vl.c
@@ -5627,7 +5627,7 @@ int main(int argc, char **argv, char **envp)
 
 ret = kvm_init(smp_cpus);
 if (ret  0) {
-#if defined(KVM_UPSTREAM) || defined(NO_CPU_EMULATION)
+#if defined(KVM_UPSTREAM) || defined(CONFIG_NO_CPU_EMULATION)
 fprintf(stderr, failed to initialize KVM\n);
 exit(1);
 #endif
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] configure: remove duplicate pkgversion

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/configure b/configure
index ea83817..f8d7402 100755
--- a/configure
+++ b/configure
@@ -236,7 +236,6 @@ blobs=yes
 pkgversion= ($(kvm_version))
 cpu_emulation=yes
 kvm_kmod=no
-pkgversion=
 check_utests=no
 user_pie=no
 
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] qemu-kvm: Reindent pc_new_cpu

2009-09-21 Thread Avi Kivity
From: Jan Kiszka jan.kis...@siemens.com

...for better match with upstream.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/hw/pc.c b/hw/pc.c
index 7e2a502..b5bef05 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1097,19 +1097,21 @@ int cpu_is_bsp(CPUState *env)
 
 CPUState *pc_new_cpu(const char *cpu_model)
 {
-CPUState *env = cpu_init(cpu_model);
-if (!env) {
-fprintf(stderr, Unable to find x86 CPU definition\n);
-exit(1);
-}
-env-kvm_cpu_state.regs_modified = 1;
-if ((env-cpuid_features  CPUID_APIC) || smp_cpus  1) {
-env-cpuid_apic_id = env-cpu_index;
-/* APIC reset callback resets cpu */
-apic_init(env);
-} else {
-qemu_register_reset((QEMUResetHandler*)cpu_reset, env);
-}
+CPUState *env;
+
+env = cpu_init(cpu_model);
+if (!env) {
+fprintf(stderr, Unable to find x86 CPU definition\n);
+exit(1);
+}
+env-kvm_cpu_state.regs_modified = 1;
+if ((env-cpuid_features  CPUID_APIC) || smp_cpus  1) {
+env-cpuid_apic_id = env-cpu_index;
+/* APIC reset callback resets cpu */
+apic_init(env);
+} else {
+qemu_register_reset((QEMUResetHandler*)cpu_reset, env);
+}
 
 /* kvm needs this to run after the apic is initialized. Otherwise,
  * it can access invalid state and crash.
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] acpi: enable/disable_processor() are used only for TARGET_I386

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Fixes a compile warning.

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/hw/acpi.c b/hw/acpi.c
index 0f80525..ff7bc4a 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -753,6 +753,7 @@ void piix4_acpi_system_hot_add_init(const char *cpu_model)
 qemu_system_device_hot_add_register(piix4_device_hot_add);
 }
 
+#if defined(TARGET_I386)
 static void enable_processor(struct gpe_regs *g, int cpu)
 {
 g-sts |= 4;
@@ -765,7 +766,6 @@ static void disable_processor(struct gpe_regs *g, int cpu)
 g-cpus_sts[cpu/8] = ~(1  (cpu%8));
 }
 
-#if defined(TARGET_I386) || defined(TARGET_X86_64)
 void qemu_system_cpu_hot_add(int cpu, int state)
 {
 CPUState *env;
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] configure: fix typos in kvm enable options

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/configure b/configure
index 6c6cb13..c567ae6 100755
--- a/configure
+++ b/configure
@@ -709,8 +709,8 @@ echo   --disable-kvmdisable KVM acceleration 
support
 echo   --enable-kvm enable KVM acceleration support
 echo   --disable-cap-kvm-pitdisable KVM pit support
 echo   --enable-cap-kvm-pit enable KVM pit support
-echo   --disable-cap-device-assigmmentdisable KVM device assignemnt
-echo   --enable-cap-device-assigmment enable KVM device assignemnt
+echo   --disable-cap-device-assignmentdisable KVM device assignment 
support
+echo   --enable-cap-device-assignment enable KVM device assignment 
support
 echo   --disable-nptl   disable usermode NPTL support
 echo   --enable-nptldisable usermode NPTL support
 echo   --enable-system  enable all system emulation targets
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] qemu-kvm: Fix guest single-stepping

2009-09-21 Thread Avi Kivity
From: Jan Kiszka jan.kis...@siemens.com

Hopefully the last regression of 4c0960c0: KVM_SET_GUEST_DEBUG requires
properly synchronized guest registers (on x86: eflags) on entry.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/qemu-kvm.c b/qemu-kvm.c
index bff11e8..6ca3b0f 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -2282,6 +2282,10 @@ static void kvm_invoke_set_guest_debug(void *data)
 {
 struct kvm_set_guest_debug_data *dbg_data = data;
 
+if (cpu_single_env-kvm_cpu_state.regs_modified) {
+kvm_arch_put_registers(cpu_single_env);
+cpu_single_env-kvm_cpu_state.regs_modified = 0;
+}
 dbg_data-err =
 kvm_set_guest_debug(cpu_single_env-kvm_cpu_state.vcpu_ctx,
 dbg_data-dbg);
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] apic: Variable only used when CAP_IRQCHIP is defined

2009-09-21 Thread Avi Kivity
From: Juan Quintela quint...@redhat.com

Signed-off-by: Juan Quintela quint...@redhat.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/hw/apic.c b/hw/apic.c
index 5ed5c98..3a2e128 100644
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -968,9 +968,9 @@ void qemu_kvm_load_lapic(CPUState *env)
 
 static void apic_pre_save(const void *opaque)
 {
+#ifdef KVM_CAP_IRQCHIP
 APICState *s = (void *)opaque;
 
-#ifdef KVM_CAP_IRQCHIP
 if (kvm_enabled()  qemu_kvm_irqchip_in_kernel()) {
 kvm_kernel_lapic_save_to_user(s);
 }
@@ -979,9 +979,9 @@ static void apic_pre_save(const void *opaque)
 
 static int apic_post_load(void *opaque)
 {
+#ifdef KVM_CAP_IRQCHIP
 APICState *s = opaque;
 
-#ifdef KVM_CAP_IRQCHIP
 if (kvm_enabled()  qemu_kvm_irqchip_in_kernel()) {
 kvm_kernel_lapic_load_from_user(s);
 }
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] MCE: Relay UCR MCE to guest

2009-09-21 Thread Avi Kivity
From: Huang Ying ying.hu...@intel.com

UCR (uncorrected recovery) MCE is supported in recent Intel CPUs,
where some hardware error such as some memory error can be reported
without PCC (processor context corrupted). To recover from such MCE,
the corresponding memory will be unmapped, and all processes accessing
the memory will be killed via SIGBUS.

For KVM, if QEMU/KVM is killed, all guest processes will be killed
too. So we relay SIGBUS from host OS to guest system via a UCR MCE
injection. Then guest OS can isolate corresponding memory and kill
necessary guest processes only. SIGBUS sent to main thread (not VCPU
threads) will be broadcast to all VCPU threads as UCR MCE.

Signed-off-by: Huang Ying ying.hu...@intel.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/cpu-common.h b/cpu-common.h
index 6302372..5e59564 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -34,6 +34,7 @@ void qemu_ram_free(ram_addr_t addr);
 /* This should only be used for ram local to a device.  */
 void *qemu_get_ram_ptr(ram_addr_t addr);
 /* This should not be used by devices.  */
+int do_qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr);
 ram_addr_t qemu_ram_addr_from_host(void *ptr);
 
 int cpu_register_io_memory(CPUReadMemoryFunc * const *mem_read,
diff --git a/exec.c b/exec.c
index aff9ec8..5c9edf7 100644
--- a/exec.c
+++ b/exec.c
@@ -2600,9 +2600,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr)
 return block-host + (addr - block-offset);
 }
 
-/* Some of the softmmu routines need to translate from a host pointer
-   (typically a TLB entry) back to a ram offset.  */
-ram_addr_t qemu_ram_addr_from_host(void *ptr)
+int do_qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)
 {
 RAMBlock *prev;
 RAMBlock **prevp;
@@ -2619,11 +2617,23 @@ ram_addr_t qemu_ram_addr_from_host(void *ptr)
 prev = block;
 block = block-next;
 }
-if (!block) {
+if (!block)
+return -1;
+*ram_addr = block-offset + (host - block-host);
+return 0;
+}
+
+/* Some of the softmmu routines need to translate from a host pointer
+   (typically a TLB entry) back to a ram offset.  */
+ram_addr_t qemu_ram_addr_from_host(void *ptr)
+{
+ram_addr_t ram_addr;
+
+if (do_qemu_ram_addr_from_host(ptr, ram_addr)) {
 fprintf(stderr, Bad ram pointer %p\n, ptr);
 abort();
 }
-return block-offset + (host - block-host);
+return ram_addr;
 }
 
 static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 1512bb8..0afdb56 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -27,10 +27,23 @@
 #include sys/mman.h
 #include sys/ioctl.h
 #include signal.h
+#include sys/signalfd.h
+#include sys/prctl.h
 
 #define false 0
 #define true 1
 
+#ifndef PR_MCE_KILL
+#define PR_MCE_KILL 33
+#endif
+
+#ifndef BUS_MCEERR_AR
+#define BUS_MCEERR_AR 4
+#endif
+#ifndef BUS_MCEERR_AO
+#define BUS_MCEERR_AO 5
+#endif
+
 #define EXPECTED_KVM_API_VERSION 12
 
 #if EXPECTED_KVM_API_VERSION != KVM_API_VERSION
@@ -1509,6 +1522,66 @@ static void sig_ipi_handler(int n)
 {
 }
 
+static void hardware_memory_error(void)
+{
+fprintf(stderr, Hardware memory error!\n);
+exit(1);
+}
+
+static void sigbus_reraise(void)
+{
+sigset_t set;
+struct sigaction action;
+
+memset(action, 0, sizeof(action));
+action.sa_handler = SIG_DFL;
+if (!sigaction(SIGBUS, action, NULL)) {
+raise(SIGBUS);
+sigemptyset(set);
+sigaddset(set, SIGBUS);
+sigprocmask(SIG_UNBLOCK, set, NULL);
+}
+perror(Failed to re-raise SIGBUS!\n);
+abort();
+}
+
+static void sigbus_handler(int n, struct signalfd_siginfo *siginfo, void *ctx)
+{
+#if defined(KVM_CAP_MCE)  defined(TARGET_I386)
+if (first_cpu-mcg_cap  siginfo-ssi_addr
+ siginfo-ssi_code == BUS_MCEERR_AO) {
+uint64_t status;
+unsigned long paddr;
+CPUState *cenv;
+
+/* Hope we are lucky for AO MCE */
+if (do_qemu_ram_addr_from_host((void *)siginfo-ssi_addr, paddr)) {
+fprintf(stderr, Hardware memory error for memory used by 
+QEMU itself instead of guest system!: %llx\n,
+(unsigned long long)siginfo-ssi_addr);
+return;
+}
+status = MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN
+| MCI_STATUS_MISCV | MCI_STATUS_ADDRV | MCI_STATUS_S
+| 0xc0;
+kvm_inject_x86_mce(first_cpu, 9, status,
+   MCG_STATUS_MCIP | MCG_STATUS_RIPV, paddr,
+   (MCM_ADDR_PHYS  6) | 0xc, 1);
+for (cenv = first_cpu-next_cpu; cenv != NULL; cenv = cenv-next_cpu)
+kvm_inject_x86_mce(cenv, 1, MCI_STATUS_VAL | MCI_STATUS_UC,
+   MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0, 1);
+} else
+#endif
+{
+if (siginfo-ssi_code == BUS_MCEERR_AO)
+return;
+else if (siginfo-ssi_code == BUS_MCEERR_AR)
+hardware_memory_error();

[COMMIT master] KVM: SVM: reorganize svm_interrupt_allowed

2009-09-21 Thread Avi Kivity
From: Joerg Roedel joerg.roe...@amd.com

This patch reorganizes the logic in svm_interrupt_allowed to
make it better to read. This is important because the logic
is a lot more complicated with Nested SVM.

Signed-off-by: Joerg Roedel joerg.roe...@amd.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 676525a..8485b40 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2459,10 +2459,18 @@ static int svm_interrupt_allowed(struct kvm_vcpu *vcpu)
 {
struct vcpu_svm *svm = to_svm(vcpu);
struct vmcb *vmcb = svm-vmcb;
-   return (vmcb-save.rflags  X86_EFLAGS_IF) 
-   !(vmcb-control.int_state  SVM_INTERRUPT_SHADOW_MASK) 
-   gif_set(svm) 
-   !(is_nested(svm)  (svm-vcpu.arch.hflags  HF_VINTR_MASK));
+   int ret;
+
+   if (!gif_set(svm) ||
+(vmcb-control.int_state  SVM_INTERRUPT_SHADOW_MASK))
+   return 0;
+
+   ret = !!(vmcb-save.rflags  X86_EFLAGS_IF);
+
+   if (is_nested(svm))
+   return ret  !(svm-vcpu.arch.hflags  HF_VINTR_MASK);
+
+   return ret;
 }
 
 static void enable_irq_window(struct kvm_vcpu *vcpu)
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6

2009-09-21 Thread Avi Kivity
From: Marcelo Tosatti mtosa...@redhat.com

Conflicts:
arch/ia64/kvm/kvm-ia64.c
arch/powerpc/include/asm/kvm_host.h
arch/x86/kvm/Makefile
arch/x86/kvm/emulate.c
arch/x86/kvm/i8254.c
arch/x86/kvm/i8259.c
arch/x86/kvm/lapic.c
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.c
include/linux/kvm_host.h
virt/kvm/eventfd.c
virt/kvm/ioapic.c
virt/kvm/irq_comm.c
virt/kvm/kvm_main.c

Signed-off-by: Marcelo Tosatti mtosa...@redhat.com
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] KVM: remove duplicated #include

2009-09-21 Thread Avi Kivity
From: Huang Weiyi weiyi.hu...@gmail.com

Remove duplicated #include('s) in
  arch/x86/kvm/lapic.c

Signed-off-by: Huang Weiyi weiyi.hu...@gmail.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 5694997..9c8f901 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -32,7 +32,6 @@
 #include asm/current.h
 #include asm/apicdef.h
 #include asm/atomic.h
-#include asm/apicdef.h
 #include kvm_cache_regs.h
 #include irq.h
 #include trace.h
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] KVM: SVM: don't copy exit_int_info on nested vmrun

2009-09-21 Thread Avi Kivity
From: Joerg Roedel joerg.roe...@amd.com

The exit_int_info field is only written by the hardware and
never read. So it does not need to be copied on a vmrun
emulation.

Signed-off-by: Joerg Roedel joerg.roe...@amd.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 8485b40..eed3201 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1795,8 +1795,6 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm)
svm-nested.intercept= nested_vmcb-control.intercept;
 
force_new_asid(svm-vcpu);
-   svm-vmcb-control.exit_int_info = nested_vmcb-control.exit_int_info;
-   svm-vmcb-control.exit_int_info_err = 
nested_vmcb-control.exit_int_info_err;
svm-vmcb-control.int_ctl = nested_vmcb-control.int_ctl | 
V_INTR_MASKING_MASK;
if (nested_vmcb-control.int_ctl  V_IRQ_MASK) {
nsvm_printk(nSVM Injecting Interrupt: 0x%x\n,
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] KVM: Activate Virtualization On Demand

2009-09-21 Thread Avi Kivity
From: Alexander Graf ag...@suse.de

X86 CPUs need to have some magic happening to enable the virtualization
extensions on them. This magic can result in unpleasant results for
users, like blocking other VMMs from working (vmx) or using invalid TLB
entries (svm).

Currently KVM activates virtualization when the respective kernel module
is loaded. This blocks us from autoloading KVM modules without breaking
other VMMs.

To circumvent this problem at least a bit, this patch introduces on
demand activation of virtualization. This means, that instead
virtualization is enabled on creation of the first virtual machine
and disabled on destruction of the last one.

So using this, KVM can be easily autoloaded, while keeping other
hypervisors usable.

Signed-off-by: Alexander Graf ag...@suse.de

--

I've tested the following:

  - shutdown
  - suspend / resume to RAM
  - suspend / resume to DISK
  - running VirtualBox while kvm module is loaded

v1 - v2

  - move failure disable into locked section
  - move vmx's ept_sync_global from init to hardware_enable
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index f6471c8..5fdeec5 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -124,7 +124,7 @@ long ia64_pal_vp_create(u64 *vpd, u64 *host_iva, u64 
*opt_handler)
 
 static  DEFINE_SPINLOCK(vp_lock);
 
-void kvm_arch_hardware_enable(void *garbage)
+int kvm_arch_hardware_enable(void *garbage)
 {
long  status;
long  tmp_base;
@@ -137,7 +137,7 @@ void kvm_arch_hardware_enable(void *garbage)
slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
local_irq_restore(saved_psr);
if (slot  0)
-   return;
+   return -EINVAL;
 
spin_lock(vp_lock);
status = ia64_pal_vp_init_env(kvm_vsa_base ?
@@ -145,7 +145,7 @@ void kvm_arch_hardware_enable(void *garbage)
__pa(kvm_vm_buffer), KVM_VM_BUFFER_BASE, tmp_base);
if (status != 0) {
printk(KERN_WARNINGkvm: Failed to Enable VT Support\n);
-   return ;
+   return -EINVAL;
}
 
if (!kvm_vsa_base) {
@@ -154,6 +154,8 @@ void kvm_arch_hardware_enable(void *garbage)
}
spin_unlock(vp_lock);
ia64_ptr_entry(0x3, slot);
+
+   return 0;
 }
 
 void kvm_arch_hardware_disable(void *garbage)
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 95af622..5902bbc 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -78,8 +78,9 @@ int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu 
*vcpu)
return r;
 }
 
-void kvm_arch_hardware_enable(void *garbage)
+int kvm_arch_hardware_enable(void *garbage)
 {
+   return 0;
 }
 
 void kvm_arch_hardware_disable(void *garbage)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 00e2ce8..5445058 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -74,9 +74,10 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
 static unsigned long long *facilities;
 
 /* Section: not file related */
-void kvm_arch_hardware_enable(void *garbage)
+int kvm_arch_hardware_enable(void *garbage)
 {
/* every s390 is virtualization enabled ;-) */
+   return 0;
 }
 
 void kvm_arch_hardware_disable(void *garbage)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 45226f0..299cc1b 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -459,7 +459,7 @@ struct descriptor_table {
 struct kvm_x86_ops {
int (*cpu_has_kvm_support)(void);  /* __init */
int (*disabled_by_bios)(void); /* __init */
-   void (*hardware_enable)(void *dummy);  /* __init */
+   int (*hardware_enable)(void *dummy);
void (*hardware_disable)(void *dummy);
void (*check_processor_compatibility)(void *rtn);
int (*hardware_setup)(void);   /* __init */
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index a2f2d43..676525a 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -316,7 +316,7 @@ static void svm_hardware_disable(void *garbage)
cpu_svm_disable();
 }
 
-static void svm_hardware_enable(void *garbage)
+static int svm_hardware_enable(void *garbage)
 {
 
struct svm_cpu_data *svm_data;
@@ -325,16 +325,20 @@ static void svm_hardware_enable(void *garbage)
struct desc_struct *gdt;
int me = raw_smp_processor_id();
 
+   rdmsrl(MSR_EFER, efer);
+   if (efer  EFER_SVME)
+   return -EBUSY;
+
if (!has_svm()) {
printk(KERN_ERR svm_cpu_init: err EOPNOTSUPP on %d\n, me);
-   return;
+   return -EINVAL;
}
svm_data = per_cpu(svm_data, me);
 
if (!svm_data) {
printk(KERN_ERR svm_cpu_init: svm_data is NULL on %d\n,
   me);
- 

[COMMIT master] KVM: SVM: Fix tsc offset adjustment when running nested

2009-09-21 Thread Avi Kivity
From: Joerg Roedel joerg.roe...@amd.com

When svm_vcpu_load is called while the vcpu is running in
guest mode the tsc adjustment made there is lost on the next
emulated #vmexit. This causes the tsc running backwards in
the guest. This patch fixes the issue by also adjusting the
tsc_offset in the emulated hsave area so that it will not
get lost.

Cc: sta...@kernel.org
Signed-off-by: Joerg Roedel joerg.roe...@amd.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index eed3201..c29d0fe 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -772,6 +772,8 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
rdtscll(tsc_this);
delta = vcpu-arch.host_tsc - tsc_this;
svm-vmcb-control.tsc_offset += delta;
+   if (is_nested(svm))
+   svm-nested.hsave-control.tsc_offset += delta;
vcpu-cpu = cpu;
kvm_migrate_timers(vcpu);
svm-asid_generation = 0;
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] KVM: SVM: Remove remaining occurences of rdtscll

2009-09-21 Thread Avi Kivity
From: Joerg Roedel joerg.roe...@amd.com

This patch replaces them with native_read_tsc() which can
also be used in expressions and saves a variable on the
stack in this case.

Signed-off-by: Joerg Roedel joerg.roe...@amd.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 41c996a..9a4daca 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -763,14 +763,13 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
int i;
 
if (unlikely(cpu != vcpu-cpu)) {
-   u64 tsc_this, delta;
+   u64 delta;
 
/*
 * Make sure that the guest sees a monotonically
 * increasing TSC.
 */
-   rdtscll(tsc_this);
-   delta = vcpu-arch.host_tsc - tsc_this;
+   delta = vcpu-arch.host_tsc - native_read_tsc();
svm-vmcb-control.tsc_offset += delta;
if (is_nested(svm))
svm-nested.hsave-control.tsc_offset += delta;
@@ -792,7 +791,7 @@ static void svm_vcpu_put(struct kvm_vcpu *vcpu)
for (i = 0; i  NR_HOST_SAVE_USER_MSRS; i++)
wrmsrl(host_save_user_msrs[i], svm-host_user_msrs[i]);
 
-   rdtscll(vcpu-arch.host_tsc);
+   vcpu-arch.host_tsc = native_read_tsc();
 }
 
 static unsigned long svm_get_rflags(struct kvm_vcpu *vcpu)
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] KVM: SVM: Handle tsc in svm_get_msr/svm_set_msr correctly

2009-09-21 Thread Avi Kivity
From: Joerg Roedel joerg.roe...@amd.com

When running nested we need to touch the l1 guests
tsc_offset. Otherwise changes will be lost or a wrong value
be read.

Cc: sta...@kernel.org
Signed-off-by: Joerg Roedel joerg.roe...@amd.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index c29d0fe..41c996a 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2064,10 +2064,14 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, unsigned 
ecx, u64 *data)
 
switch (ecx) {
case MSR_IA32_TSC: {
-   u64 tsc;
+   u64 tsc_offset;
 
-   rdtscll(tsc);
-   *data = svm-vmcb-control.tsc_offset + tsc;
+   if (is_nested(svm))
+   tsc_offset = svm-nested.hsave-control.tsc_offset;
+   else
+   tsc_offset = svm-vmcb-control.tsc_offset;
+
+   *data = tsc_offset + native_read_tsc();
break;
}
case MSR_K6_STAR:
@@ -2153,10 +2157,17 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned 
ecx, u64 data)
 
switch (ecx) {
case MSR_IA32_TSC: {
-   u64 tsc;
+   u64 tsc_offset = data - native_read_tsc();
+   u64 g_tsc_offset = 0;
+
+   if (is_nested(svm)) {
+   g_tsc_offset = svm-vmcb-control.tsc_offset -
+  svm-nested.hsave-control.tsc_offset;
+   svm-nested.hsave-control.tsc_offset = tsc_offset;
+   }
+
+   svm-vmcb-control.tsc_offset = tsc_offset + g_tsc_offset;
 
-   rdtscll(tsc);
-   svm-vmcb-control.tsc_offset = data - tsc;
break;
}
case MSR_K6_STAR:
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] KVM: s390: fix memsize = 4G

2009-09-21 Thread Avi Kivity
From: Christian Borntraeger borntrae...@de.ibm.com

commit 628eb9b8a8f3
KVM: s390: streamline memslot handling

introduced kvm_s390_vcpu_get_memsize. This broke guests =4G, since this
function returned an int.

This patch changes the return value to a long.

Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index ec5eee7..06cce82 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -58,7 +58,7 @@ int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
 int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code);
 int kvm_s390_inject_sigp_stop(struct kvm_vcpu *vcpu, int action);
 
-static inline int kvm_s390_vcpu_get_memsize(struct kvm_vcpu *vcpu)
+static inline long kvm_s390_vcpu_get_memsize(struct kvm_vcpu *vcpu)
 {
return vcpu-arch.sie_block-gmslm
- vcpu-arch.sie_block-gmsor
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] compatfd: complete definition

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/compatfd.h b/compatfd.h
index 55a111a..06b0b6b 100644
--- a/compatfd.h
+++ b/compatfd.h
@@ -17,8 +17,25 @@
 #include signal.h
 
 struct qemu_signalfd_siginfo {
-uint32_t ssi_signo;
-uint8_t pad[124];
+uint32_t ssi_signo;   /* Signal number */
+int32_t  ssi_errno;   /* Error number (unused) */
+int32_t  ssi_code;/* Signal code */
+uint32_t ssi_pid; /* PID of sender */
+uint32_t ssi_uid; /* Real UID of sender */
+int32_t  ssi_fd;  /* File descriptor (SIGIO) */
+uint32_t ssi_tid; /* Kernel timer ID (POSIX timers) */
+uint32_t ssi_band;/* Band event (SIGIO) */
+uint32_t ssi_overrun; /* POSIX timer overrun count */
+uint32_t ssi_trapno;  /* Trap number that caused signal */
+int32_t  ssi_status;  /* Exit status or signal (SIGCHLD) */
+int32_t  ssi_int; /* Integer sent by sigqueue(2) */
+uint64_t ssi_ptr; /* Pointer sent by sigqueue(2) */
+uint64_t ssi_utime;   /* User CPU time consumed (SIGCHLD) */
+uint64_t ssi_stime;   /* System CPU time consumed (SIGCHLD) */
+uint64_t ssi_addr;/* Address that generated signal
+ (for hardware-generated signals) */
+uint8_t  pad[48]; /* Pad size to 128 bytes (allow for
+ additional fields in the future) */
 };
 
 int qemu_signalfd(const sigset_t *mask);
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Merge branch 'upstream-merge'

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

* upstream-merge: (44 commits)
  Compile host-utils only once
  Compile TCG runtime library only once
  Fix spelling in comment
  Compile ne2000 only once
  ioports: remove unused env parameter and compile only once
  Compile msix only once
  Compile loader only once
  Compile qemu-config only once
  Compile wdt_i6300esb only once
  Fix mingw32 compile
  Probe for fdatasync()
  PPC: make system bus parent of PCI bus
  Fix indentation
  ESP: convert to VMState
  target-alpha: fix extlh instruction
  target-ppc: optimize slw/srw/sld/srd
  audio: use correct email address
  audio: internal API change
  sdlaudio: use correct function names in sdl_XXX calls
  oss: use audio_pcm_hw_clip_out
  ...

Signed-off-by: Avi Kivity a...@redhat.com
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Make compatfd.c depend on CONFIG_POSIX

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

It does not build on Windows.

Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/Makefile b/Makefile
index 1e09953..25a6df3 100644
--- a/Makefile
+++ b/Makefile
@@ -67,7 +67,7 @@ block-obj-y = cutils.o cache-utils.o qemu-malloc.o 
qemu-option.o module.o
 block-obj-y += nbd.o block.o aio.o aes.o osdep.o
 block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
-block-obj-y += compatfd.o
+block-obj-$(CONFIG_POSIX) += compatfd.o
 
 block-nested-y += cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o
 block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Use compatfd.h instead of sys/signalfd.h

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

sys/signalfd.h is not always available, and it too intrusive to conditionally
compile the MCE injection support code.

Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/qemu-kvm.c b/qemu-kvm.c
index 0afdb56..99b3f2c 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -26,7 +26,7 @@
 #include sys/syscall.h
 #include sys/mman.h
 #include sys/ioctl.h
-#include signal.h
+#include compatfd.h
 #include sys/signalfd.h
 #include sys/prctl.h
 
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[COMMIT master] Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6

2009-09-21 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

Signed-off-by: Avi Kivity a...@redhat.com
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] Virtual Machine Device Queues(VMDq) support on KVM

2009-09-21 Thread Rusty Russell
On Wed, 2 Sep 2009 01:35:18 am Stephen Hemminger wrote:
 On Tue, 1 Sep 2009 14:58:19 +0800
 Xin, Xiaohui xiaohui@intel.com wrote:
 
[RFC] Virtual Machine Device Queues (VMDq) support on KVM
  
  Network adapter with VMDq technology presents multiple pairs of tx/rx 
  queues,
  and renders network L2 sorting mechanism based on MAC addresses and VLAN 
  tags
  for each tx/rx queue pair. Here we present a generic framework, in which 
  network
  traffic to/from a tx/rx queue pair can be directed from/to a KVM guest 
  without
  any software copy.
  
  Actually this framework can apply to traditional network adapters which have
  just one tx/rx queue pair. And applications using the same user/kernel 
  interface
  can utilize this framework to send/receive network traffic directly thru a 
  tx/rx
  queue pair in a network adapter.
  
  We use virtio-net architecture to illustrate the framework.
  
  
  || pop   add_buf||
  |Qemu process|  -TX   --  | Guest Kernel   |
  ||  - --  ||
  |Virtio-net  | push  get_buf||
  |  (Backend service) |  -RX   --  |  Virtio-net|
  ||  - --  |driver  |
  || push  get_buf||
  ||  ||
 |
 |
 | AIO (read  write) combined with Direct I/O
 |   (which substitute synced file operations)
  |---|
  | Host kernel  | read: copy-less with directly mapped user  |
  |  |   space to kernel, payload directly DMAed  |
  |  |   into user space  |
  |  | write: copy-less with directly mapped user |
  |  |   space to kernel, payload directly hooked |
  |  |   to a skb |
  |  ||
  |  (a likely   ||
  |   queue pair ||
  |   instance)  ||
  |  |   ||
  | NIC driver --  TUN/TAP driver   |
  |---|
 |
 |
 traditional adapter or a tx/rx queue pair
  
  The basic idea is to utilize the kernel Asynchronous I/O combined with 
  Direct
  I/O to implements copy-less TUN/TAP device. AIO and Direct I/O is not new to
  kernel, we still can see it in SCSI tape driver.
  
  With traditional file operations, a copying of payload contents from/to the
  kernel DMA address to/from a user buffer is needed. That's what the copying 
  we
  want to save.
  
  The proposed framework is like this:
  A TUN/TAP device is bound to a traditional NIC adapter or a tx/rx queue 
  pair in
  host side. KVM virto-net Backend service, the user space program submits
  asynchronous read/write I/O requests to the host kernel through TUN/TAP 
  device.
  The requests are corresponding to the vqueue elements include both 
  transmission
   receive. They can be queued in one AIO request and later, the completion 
  will
  be notified through the underlying packets tx/rx processing of the rx/tx 
  queue
  pair.
  
  Detailed path:
  
  To guest Virtio-net driver, packets receive corresponding to asynchronous 
  read
  I/O requests of Backend service.
  
  1) Guest Virtio-net driver provides header and payload address through the
  receive vqueue to Virtio-net backend service.
  
  2) Virtio-net backend service encapsulates multiple vqueue elements into
  multiple AIO control blocks and composes them into one AIO read request.
  
  3) Virtio-net backend service uses io_submit() syscall to pass the request 
  to
  the TUN/TAP device.
  
  4) Virtio-net backend service uses io_getevents() syscall to check the
  completion of the request.
  
  5) The TUN/TAP driver receives packets from the queue pair of NIC, and 
  prepares
  for Direct I/O.
 A modified NIC driver may render a skb which header is allocated in host
  kernel, but the payload buffer is directly mapped from user space buffer 
  which
  are rendered through the AIO request by the Backend service. 
  get_user_pages()
  may do this. For one AIO read request, the TUN/TAP driver maintains a list 
  for
  the directly mapped buffers, and a NIC driver tries to get the buffers as
  payload buffer to compose the new skbs. Of course, if 

[PATCH 1/3] fix typo

2009-09-21 Thread Juan Quintela

Signed-off-by: Juan Quintela quint...@redhat.com
---
 configure |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index ee37ea1..080e3b6 100755
--- a/configure
+++ b/configure
@@ -709,8 +709,8 @@ echo   --disable-kvmdisable KVM acceleration 
support
 echo   --enable-kvm enable KVM acceleration support
 echo   --disable-cap-kvm-pitdisable KVM pit support
 echo   --enable-cap-kvm-pit enable KVM pit support
-echo   --disable-cap-device-assigmmentdisable KVM device assignemnt
-echo   --enable-cap-device-assigmment enable KVM device assignemnt
+echo   --disable-cap-device-assignmentdisable KVM device assignemnt
+echo   --enable-cap-device-assignment enable KVM device assignemnt
 echo   --disable-nptl   disable usermode NPTL support
 echo   --enable-nptldisable usermode NPTL support
 echo   --enable-system  enable all system emulation targets
-- 
1.6.2.5

--
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/2] make --disable-kvm to compile again (now all arches)

2009-09-21 Thread Juan Quintela
Hi
   With this patch on top of my yesterday fixes, you can compile all
   architectures with/without --enable-kvm.

Later, Juan.

PD. This series are also known as make Jan Kiszka happy :)

Juan Quintela (2):
  acpi: enable/disable_processor() are used only for TARGET_I386
  vga: move back dirty_log functions to vga.c

 hw/acpi.c|2 +-
 hw/vga-pci.c |   43 ---
 hw/vga.c |   43 +++
 3 files changed, 44 insertions(+), 44 deletions(-)

--
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/2] acpi: enable/disable_processor() are used only for TARGET_I386

2009-09-21 Thread Juan Quintela

Signed-off-by: Juan Quintela quint...@redhat.com
---
 hw/acpi.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/acpi.c b/hw/acpi.c
index 0f80525..ff7bc4a 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -753,6 +753,7 @@ void piix4_acpi_system_hot_add_init(const char *cpu_model)
 qemu_system_device_hot_add_register(piix4_device_hot_add);
 }

+#if defined(TARGET_I386)
 static void enable_processor(struct gpe_regs *g, int cpu)
 {
 g-sts |= 4;
@@ -765,7 +766,6 @@ static void disable_processor(struct gpe_regs *g, int cpu)
 g-cpus_sts[cpu/8] = ~(1  (cpu%8));
 }

-#if defined(TARGET_I386) || defined(TARGET_X86_64)
 void qemu_system_cpu_hot_add(int cpu, int state)
 {
 CPUState *env;
-- 
1.6.2.5

--
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 2/2] vga: move back dirty_log functions to vga.c

2009-09-21 Thread Juan Quintela

Signed-off-by: Juan Quintela quint...@redhat.com
---
 hw/vga-pci.c |   43 ---
 hw/vga.c |   43 +++
 2 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/hw/vga-pci.c b/hw/vga-pci.c
index c49858c..9bb2d81 100644
--- a/hw/vga-pci.c
+++ b/hw/vga-pci.c
@@ -28,7 +28,6 @@
 #include vga_int.h
 #include pixel_ops.h
 #include qemu-timer.h
-#include kvm.h

 typedef struct PCIVGAState {
 PCIDevice dev;
@@ -59,48 +58,6 @@ static int pci_vga_load(QEMUFile *f, void *opaque, int 
version_id)
 return vga_common_load(f, s-vga, version_id);
 }

-static int s1, s2;
-
-static void mark_dirty(target_phys_addr_t start, target_phys_addr_t len)
-{
-target_phys_addr_t end = start + len;
-
-while (start  end) {
-cpu_physical_memory_set_dirty(cpu_get_physical_page_desc(start));
-start += TARGET_PAGE_SIZE;
-}
-}
-
-void vga_dirty_log_start(VGACommonState *s)
-{
-if (kvm_enabled()  s-map_addr)
-if (!s1) {
-kvm_log_start(s-map_addr, s-map_end - s-map_addr);
-mark_dirty(s-map_addr, s-map_end - s-map_addr);
-s1 = 1;
-}
-if (kvm_enabled()  s-lfb_vram_mapped) {
-if (!s2) {
-kvm_log_start(isa_mem_base + 0xa, 0x8000);
-kvm_log_start(isa_mem_base + 0xa8000, 0x8000);
-mark_dirty(isa_mem_base + 0xa, 0x1);
-}
-s2 = 1;
-}
-}
-
-void vga_dirty_log_stop(VGACommonState *s)
-{
-if (kvm_enabled()  s-map_addr  s1)
-kvm_log_stop(s-map_addr, s-map_end - s-map_addr);
-
-if (kvm_enabled()  s-lfb_vram_mapped  s2) {
-kvm_log_stop(isa_mem_base + 0xa, 0x8000);
-kvm_log_stop(isa_mem_base + 0xa8000, 0x8000);
-}
-s1 = s2 = 0;
-}
-
 static void vga_map(PCIDevice *pci_dev, int region_num,
 uint32_t addr, uint32_t size, int type)
 {
diff --git a/hw/vga.c b/hw/vga.c
index df4c063..29a9f81 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -28,6 +28,7 @@
 #include vga_int.h
 #include pixel_ops.h
 #include qemu-timer.h
+#include kvm.h

 //#define DEBUG_VGA
 //#define DEBUG_VGA_MEM
@@ -1579,6 +1580,48 @@ static void vga_sync_dirty_bitmap(VGACommonState *s)
 vga_dirty_log_start(s);
 }

+static int s1, s2;
+
+static void mark_dirty(target_phys_addr_t start, target_phys_addr_t len)
+{
+target_phys_addr_t end = start + len;
+
+while (start  end) {
+cpu_physical_memory_set_dirty(cpu_get_physical_page_desc(start));
+start += TARGET_PAGE_SIZE;
+}
+}
+
+void vga_dirty_log_start(VGACommonState *s)
+{
+if (kvm_enabled()  s-map_addr)
+if (!s1) {
+kvm_log_start(s-map_addr, s-map_end - s-map_addr);
+mark_dirty(s-map_addr, s-map_end - s-map_addr);
+s1 = 1;
+}
+if (kvm_enabled()  s-lfb_vram_mapped) {
+if (!s2) {
+kvm_log_start(isa_mem_base + 0xa, 0x8000);
+kvm_log_start(isa_mem_base + 0xa8000, 0x8000);
+mark_dirty(isa_mem_base + 0xa, 0x1);
+}
+s2 = 1;
+}
+}
+
+void vga_dirty_log_stop(VGACommonState *s)
+{
+if (kvm_enabled()  s-map_addr  s1)
+kvm_log_stop(s-map_addr, s-map_end - s-map_addr);
+
+if (kvm_enabled()  s-lfb_vram_mapped  s2) {
+kvm_log_stop(isa_mem_base + 0xa, 0x8000);
+kvm_log_stop(isa_mem_base + 0xa8000, 0x8000);
+}
+s1 = s2 = 0;
+}
+
 /*
  * graphic modes
  */
-- 
1.6.2.5

--
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 1/3] fix typo

2009-09-21 Thread Bernhard Held

There are two more typos:


+echo   --disable-cap-device-assignmentdisable KVM device assignemnt

   ^

+echo   --enable-cap-device-assignment enable KVM device assignemnt

  ^

Bernhard

--
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] kvm-s390: fix memsize =4G on linus git head

2009-09-21 Thread Christian Borntraeger
Avi, Marcelo,


commit 628eb9b8a8f3ef31d8316112a4596b1a21b38159
KVM: s390: streamline memslot handling

introduced kvm_s390_vcpu_get_memsize. This broke guests =4G, since this 
function returned an int.

This patch changes the return value to a long.


Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com

---
 arch/s390/kvm/kvm-s390.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/arch/s390/kvm/kvm-s390.h
===
--- linux-2.6.orig/arch/s390/kvm/kvm-s390.h
+++ linux-2.6/arch/s390/kvm/kvm-s390.h
@@ -58,7 +58,7 @@ int kvm_s390_inject_vcpu(struct kvm_vcpu
 int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code);
 int kvm_s390_inject_sigp_stop(struct kvm_vcpu *vcpu, int action);
 
-static inline int kvm_s390_vcpu_get_memsize(struct kvm_vcpu *vcpu)
+static inline long kvm_s390_vcpu_get_memsize(struct kvm_vcpu *vcpu)
 {
return vcpu-arch.sie_block-gmslm
- vcpu-arch.sie_block-gmsor
--
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 v2] fix typo

2009-09-21 Thread Juan Quintela
Quintela learns to spell long words.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 configure |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index ee37ea1..42152de 100755
--- a/configure
+++ b/configure
@@ -709,8 +709,8 @@ echo   --disable-kvmdisable KVM acceleration 
support
 echo   --enable-kvm enable KVM acceleration support
 echo   --disable-cap-kvm-pitdisable KVM pit support
 echo   --enable-cap-kvm-pit enable KVM pit support
-echo   --disable-cap-device-assigmmentdisable KVM device assignemnt
-echo   --enable-cap-device-assigmment enable KVM device assignemnt
+echo   --disable-cap-device-assignmentdisable KVM device assignment 
support
+echo   --enable-cap-device-assignment enable KVM device assignment 
support
 echo   --disable-nptl   disable usermode NPTL support
 echo   --enable-nptldisable usermode NPTL support
 echo   --enable-system  enable all system emulation targets
-- 
1.6.2.5

--
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


[KVM-AUTOTEST PATCH] Adding NAS Parallel Benchmarks(NPB) as client test [1/2]

2009-09-21 Thread Cao, Chen
- Using NPB OpenMP implementaion.

Signed-off-by: Cao, Chen k...@redhat.com
---
 client/tests/kvm/kvm_tests.cfg.sample   |4 +
 client/tests/npb/control|   28 
 client/tests/npb/enable-all-tests.patch |  233 +++
 client/tests/npb/npb.py |   95 +
 4 files changed, 360 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/npb/control
 create mode 100644 client/tests/npb/enable-all-tests.patch
 create mode 100644 client/tests/npb/npb.py

diff --git a/client/tests/kvm/kvm_tests.cfg.sample 
b/client/tests/kvm/kvm_tests.cfg.sample
index 285a38f..0b2ab37 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -90,6 +90,10 @@ variants:
 - disktest:
 test_name = disktest
 test_control_file = disktest.control
+- npb:
+test_name = npb
+test_control_file = npb.control
+extra_params +=  -smp 2
 
 - linux_s3: install setup
 type = linux_s3
diff --git a/client/tests/npb/control b/client/tests/npb/control
new file mode 100644
index 000..d6c2adb
--- /dev/null
+++ b/client/tests/npb/control
@@ -0,0 +1,28 @@
+NAME = NAS Parallel Benchmarks
+AUTHOR = Cao, Chen k...@redhat.com
+TEST_TYPE = CLIENT
+TEST_CLASS = HARDWARE
+TEST_CATEGORY = BENCHMARK
+TIME = MEDIUM
+DOC = \
+Using NPB, OpenMP implementation.
+
+See http://www.nas.nasa.gov/Software/NPB/
+
+
+# Supported tests (benchmarks):
+#   bt.A bt.B bt.C bt.D bt.E bt.S bt.W
+#   cg.A cg.B cg.C cg.S cg.W
+#   dc.A dc.B dc.S dc.W
+#   ep.A ep.B ep.C ep.D ep.E ep.S ep.W
+#   ft.A ft.B ft.S ft.W
+#   is.A is.B is.C is.S is.W
+#   lu.A lu.B lu.C lu.S lu.W
+#   mg.A mg.B mg.S mg.W
+#   sp.A sp.B sp.C sp.D sp.E sp.S sp.W
+#   ua.A ua.B ua.C ua.S ua.W
+#
+# Please refer to npb.py for more infomation about
+# the arguments.
+job.run_test(url='npb', tests='ep.A ep.B', ratio=0.5)
+
diff --git a/client/tests/npb/enable-all-tests.patch 
b/client/tests/npb/enable-all-tests.patch
new file mode 100644
index 000..f08a9d3
--- /dev/null
+++ b/client/tests/npb/enable-all-tests.patch
@@ -0,0 +1,233 @@
+diff --git a/NPB3.3-OMP/config/make.def b/NPB3.3-OMP/config/make.def
+new file mode 100644
+index 000..afffe7d
+--- /dev/null
 b/NPB3.3-OMP/config/make.def
+@@ -0,0 +1,161 @@
++#---
++#
++#SITE- AND/OR PLATFORM-SPECIFIC DEFINITIONS. 
++#
++#---
++
++#---
++# Items in this file will need to be changed for each platform.
++#---
++
++#---
++# Parallel Fortran:
++#
++# For CG, EP, FT, MG, LU, SP, BT and UA, which are in Fortran, the following 
++# must be defined:
++#
++# F77- Fortran compiler
++# FFLAGS - Fortran compilation arguments
++# F_INC  - any -I arguments required for compiling Fortran 
++# FLINK  - Fortran linker
++# FLINKFLAGS - Fortran linker arguments
++# F_LIB  - any -L and -l arguments required for linking Fortran 
++# 
++# compilations are done with $(F77) $(F_INC) $(FFLAGS) or
++#$(F77) $(FFLAGS)
++# linking is done with   $(FLINK) $(F_LIB) $(FLINKFLAGS)
++#---
++
++#---
++# This is the fortran compiler used for Fortran programs
++#---
++F77 = gfortran
++# This links fortran programs; usually the same as ${F77}
++FLINK = $(F77)
++
++#---
++# These macros are passed to the linker 
++#---
++F_LIB  =
++
++#---
++# These macros are passed to the compiler 
++#---
++F_INC =
++
++#---
++# Global *compile time* flags for Fortran programs
++#---
++FFLAGS= -O -fopenmp 
++
++#---
++# Global *link time* flags. Flags for increasing maximum executable 
++# size usually go here. 
++#---
++FLINKFLAGS = -O -fopenmp 
++
++
++#---
++# Parallel C:
++#
++# For IS and 

[KVM-AUTOTEST PATCH] Adding NAS Parallel Benchmarks(NPB) as client test [2/2]

2009-09-21 Thread Ken Cao
The source code of NPB.
Please check the attachment.

relative path:
client/tests/npb/NPB3.3.tar.gz


Thanks.

Cao, Chen
2009/09/21
--
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 QEMU-KVM 0/7] test: more IPI tests

2009-09-21 Thread Avi Kivity
The following patchset, besides fixing IPIs to actually work, adds two
IPI latency tests (back-to-back IPIs and IPI-then-spin) and improves
the framework a bit.

Avi Kivity (7):
  test: issue EOI after IPI
  test: set up per-cpu area
  test: optimize smp_id()
  test: add conditional execution for vmexit tests
  test: add ipi latency test
  test: Add ipi_halt benchmark
  test: Auto-tune vmexit test

 kvm/user/test/lib/x86/smp.c  |   18 +-
 kvm/user/test/x86/cstart64.S |   11 +
 kvm/user/test/x86/vmexit.c   |   51 +-
 3 files changed, 72 insertions(+), 8 deletions(-)

--
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 QEMU-KVM 2/7] test: set up per-cpu area

2009-09-21 Thread Avi Kivity
Currently sharing space with the stack.

Signed-off-by: Avi Kivity a...@redhat.com
---
 kvm/user/test/x86/cstart64.S |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/kvm/user/test/x86/cstart64.S b/kvm/user/test/x86/cstart64.S
index e5554ba..f1a9d09 100644
--- a/kvm/user/test/x86/cstart64.S
+++ b/kvm/user/test/x86/cstart64.S
@@ -80,9 +80,19 @@ mb_flags = 0x0
# multiboot header
.long mb_magic, mb_flags, 0 - (mb_magic + mb_flags)
 
+MSR_GS_BASE = 0xc101
+
+.macro setup_percpu_area
+   lea -4096(%esp), %eax
+   mov $0, %edx
+   mov $MSR_GS_BASE, %ecx
+   wrmsr
+.endm
+
 .globl start
 start:
mov $stacktop, %esp
+   setup_percpu_area
call prepare_64
jmpl $8, $start64
 
@@ -142,6 +152,7 @@ ap_start32:
mov %ax, %ss
mov $-4096, %esp
lock/xaddl %esp, smp_stacktop
+   setup_percpu_area
call prepare_64
ljmpl $8, $ap_start64
 
-- 
1.6.4.1

--
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 QEMU-KVM 3/7] test: optimize smp_id()

2009-09-21 Thread Avi Kivity
Rather than reading it from the APIC, read it from the per-cpu
area.

Signed-off-by: Avi Kivity a...@redhat.com
---
 kvm/user/test/lib/x86/smp.c |   17 +++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/kvm/user/test/lib/x86/smp.c b/kvm/user/test/lib/x86/smp.c
index 25f0cae..9eface5 100644
--- a/kvm/user/test/lib/x86/smp.c
+++ b/kvm/user/test/lib/x86/smp.c
@@ -71,13 +71,21 @@ int cpu_count(void)
 
 int smp_id(void)
 {
-return apic_read(APIC_ID);
+unsigned id;
+
+asm (mov %%gs:0, %0 : =r(id));
+return id;
+}
+
+static void setup_smp_id(void *data)
+{
+asm (mov %0, %%gs:0 : : r(apic_id()) : memory);
 }
 
 void on_cpu(int cpu, void (*function)(void *data), void *data)
 {
 spin_lock(ipi_lock);
-if (cpu == apic_id())
+if (cpu == smp_id())
function(data);
 else {
ipi_function = function;
@@ -98,4 +106,9 @@ void smp_init(void)
 void ipi_entry(void);
 
 set_ipi_descriptor(ipi_entry);
+
+setup_smp_id(0);
+for (i = 1; i  cpu_count(); ++i)
+on_cpu(i, setup_smp_id, 0);
+
 }
-- 
1.6.4.1

--
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 QEMU-KVM 1/7] test: issue EOI after IPI

2009-09-21 Thread Avi Kivity
Otherwise, we can't take more than one IPI.

Signed-off-by: Avi Kivity a...@redhat.com
---
 kvm/user/test/lib/x86/smp.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kvm/user/test/lib/x86/smp.c b/kvm/user/test/lib/x86/smp.c
index a3a5472..25f0cae 100644
--- a/kvm/user/test/lib/x86/smp.c
+++ b/kvm/user/test/lib/x86/smp.c
@@ -14,6 +14,7 @@ static volatile int ipi_done;
 static __attribute__((used)) void ipi()
 {
 ipi_function(ipi_data);
+apic_write(APIC_EOI, 0);
 ipi_done = 1;
 }
 
-- 
1.6.4.1

--
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 QEMU-KVM 4/7] test: add conditional execution for vmexit tests

2009-09-21 Thread Avi Kivity
ipi tests can only run on smp for example.

Signed-off-by: Avi Kivity a...@redhat.com
---
 kvm/user/test/x86/vmexit.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c
index cce26d9..76f676d 100644
--- a/kvm/user/test/x86/vmexit.c
+++ b/kvm/user/test/x86/vmexit.c
@@ -54,6 +54,7 @@ static void mov_to_cr8(void)
 static struct test {
void (*func)(void);
const char *name;
+   int (*valid)(void);
 } tests[] = {
{ cpuid, cpuid, },
{ vmcall, vmcall, },
@@ -67,6 +68,11 @@ static void do_test(struct test *test)
unsigned long long t1, t2;
 void (*func)(void) = test-func;
 
+if (test-valid  !test-valid()) {
+   printf(%s (skipped)\n, test-name);
+   return;
+   }
+
t1 = rdtsc();
for (i = 0; i  N; ++i)
 func();
-- 
1.6.4.1

--
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 QEMU-KVM 6/7] test: Add ipi_halt benchmark

2009-09-21 Thread Avi Kivity
Wait for 2000 cycles after the IPI to allow the host to schedule out.
Measures wake-from-idle overhead.

Signed-off-by: Avi Kivity a...@redhat.com
---
 kvm/user/test/x86/vmexit.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c
index 29bb32a..5088dc9 100644
--- a/kvm/user/test/x86/vmexit.c
+++ b/kvm/user/test/x86/vmexit.c
@@ -66,6 +66,16 @@ static void ipi(void)
on_cpu(1, nop, 0);
 }
 
+static void ipi_halt(void)
+{
+   unsigned long long t;
+
+   on_cpu(1, nop, 0);
+   t = rdtsc() + 2000;
+   while (rdtsc()  t)
+   ;
+}
+
 static struct test {
void (*func)(void);
const char *name;
@@ -76,6 +86,7 @@ static struct test {
{ mov_from_cr8, mov_from_cr8 },
{ mov_to_cr8, mov_to_cr8 },
{ ipi, ipi, is_smp },
+   { ipi_halt, ipi+halt, is_smp },
 };
 
 static void do_test(struct test *test)
-- 
1.6.4.1

--
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 QEMU-KVM 5/7] test: add ipi latency test

2009-09-21 Thread Avi Kivity
Signed-off-by: Avi Kivity a...@redhat.com
---
 kvm/user/test/x86/vmexit.c |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c
index 76f676d..29bb32a 100644
--- a/kvm/user/test/x86/vmexit.c
+++ b/kvm/user/test/x86/vmexit.c
@@ -1,5 +1,6 @@
 
 #include libcflat.h
+#include smp.h
 
 static inline unsigned long long rdtsc()
 {
@@ -51,6 +52,20 @@ static void mov_to_cr8(void)
asm volatile (mov %0, %%cr8 : : r(cr8));
 }
 
+static int is_smp(void)
+{
+   return cpu_count()  1;
+}
+
+static void nop(void *junk)
+{
+}
+
+static void ipi(void)
+{
+   on_cpu(1, nop, 0);
+}
+
 static struct test {
void (*func)(void);
const char *name;
@@ -60,6 +75,7 @@ static struct test {
{ vmcall, vmcall, },
{ mov_from_cr8, mov_from_cr8 },
{ mov_to_cr8, mov_to_cr8 },
+   { ipi, ipi, is_smp },
 };
 
 static void do_test(struct test *test)
@@ -86,6 +102,8 @@ int main(void)
 {
int i;
 
+   smp_init();
+
for (i = 0; i  ARRAY_SIZE(tests); ++i)
do_test(tests[i]);
 
-- 
1.6.4.1

--
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 QEMU-KVM 7/7] test: Auto-tune vmexit test

2009-09-21 Thread Avi Kivity
Scale up iterations until we measure at least 1G cycles.

Signed-off-by: Avi Kivity a...@redhat.com
---
 kvm/user/test/x86/vmexit.c |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c
index 5088dc9..e7cb5ef 100644
--- a/kvm/user/test/x86/vmexit.c
+++ b/kvm/user/test/x86/vmexit.c
@@ -17,7 +17,7 @@ static inline unsigned long long rdtsc()
return r;
 }
 
-#define N (1  22)
+#define GOAL (1ull  30)
 
 #ifdef __x86_64__
 #  define R r
@@ -93,6 +93,7 @@ static void do_test(struct test *test)
 {
int i;
unsigned long long t1, t2;
+   unsigned iterations = 32;
 void (*func)(void) = test-func;
 
 if (test-valid  !test-valid()) {
@@ -100,11 +101,14 @@ static void do_test(struct test *test)
return;
}
 
-   t1 = rdtsc();
-   for (i = 0; i  N; ++i)
-func();
-   t2 = rdtsc();
-   printf(%s %d\n, test-name, (int)((t2 - t1) / N));
+   do {
+   iterations *= 2;
+   t1 = rdtsc();
+   for (i = 0; i  iterations; ++i)
+   func();
+   t2 = rdtsc();
+   } while ((t2 - t1)  GOAL);
+   printf(%s %d\n, test-name, (int)((t2 - t1) / iterations));
 }
 
 #define ARRAY_SIZE(_x) (sizeof(_x) / sizeof((_x)[0]))
-- 
1.6.4.1

--
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] kvm-s390: fix memsize =4G on linus git head

2009-09-21 Thread Avi Kivity

On 09/21/2009 11:45 AM, Christian Borntraeger wrote:

Avi, Marcelo,


commit 628eb9b8a8f3ef31d8316112a4596b1a21b38159
 KVM: s390: streamline memslot handling

introduced kvm_s390_vcpu_get_memsize. This broke guests=4G, since this
function returned an int.

This patch changes the return value to a long.
   


Applied and queued.  Thanks.

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

--
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 04/24] piix4_dev is not used for pc's

2009-09-21 Thread Avi Kivity

On 09/19/2009 12:42 AM, Juan Quintela wrote:



Not applying because its dead code with the current state of pc.c
configuration but this prevents one to use piix4.
 

piix4 is not used for pci irq assignement in pc.  It is only used on
mips.  I am the one that split the file in qemu upstream.  piix4 and
piix3 are the same from the irq point of view.

next pc chipset is not going to be piix4 :)
   


I agree with Marcelo - even if mips never gains device assignment or pc 
never uses piix4, the code is more complete the way it is.


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

--
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 23/24] Get CONFIG_CPU_EMULATION back to life

2009-09-21 Thread Avi Kivity

On 09/19/2009 12:44 AM, Juan Quintela wrote:

Marcelo Tosattimtosa...@redhat.com  wrote:
   

On Fri, Sep 18, 2009 at 01:41:34PM +0200, Juan Quintela wrote:
 

Code compile with --disable-cpu-emulation, and that don't compile
tcg.  This is the minimal set of changes to get it working
   

Better see this upstreamed (and perhaps remove support from qemu-kvm,
unless someone disagrees).
 

I am told it is needed for ia64 support.  But as ia64 port is not being
too active, it don't matter too much.
   


Applied, but can you look at upstreaming this?  Thanks.

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

--
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 v2] fix typo

2009-09-21 Thread Avi Kivity

On 09/21/2009 11:46 AM, Juan Quintela wrote:

Quintela learns to spell long words.
   


Applied, thanks.

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

--
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/2] make --disable-kvm to compile again (now all arches)

2009-09-21 Thread Avi Kivity

On 09/21/2009 11:19 AM, Juan Quintela wrote:

Hi
With this patch on top of my yesterday fixes, you can compile all
architectures with/without --enable-kvm.
   


Applied, thanks.

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

--
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: [Autotest] [KVM-AUTOTEST PATCH] Adding NAS Parallel Benchmarks(NPB) as client test [1/2]

2009-09-21 Thread Michael Goldish

- Chen Cao k...@redhat.com wrote:

 - Using NPB OpenMP implementaion.
 
 Signed-off-by: Cao, Chen k...@redhat.com
 ---
  client/tests/kvm/kvm_tests.cfg.sample   |4 +
  client/tests/npb/control|   28 
  client/tests/npb/enable-all-tests.patch |  233
 +++
  client/tests/npb/npb.py |   95 +
  4 files changed, 360 insertions(+), 0 deletions(-)
  create mode 100644 client/tests/npb/control
  create mode 100644 client/tests/npb/enable-all-tests.patch
  create mode 100644 client/tests/npb/npb.py
 
 diff --git a/client/tests/kvm/kvm_tests.cfg.sample
 b/client/tests/kvm/kvm_tests.cfg.sample
 index 285a38f..0b2ab37 100644
 --- a/client/tests/kvm/kvm_tests.cfg.sample
 +++ b/client/tests/kvm/kvm_tests.cfg.sample
 @@ -90,6 +90,10 @@ variants:
  - disktest:
  test_name = disktest
  test_control_file = disktest.control
 +- npb:
 +test_name = npb
 +test_control_file = npb.control
 +extra_params +=  -smp 2

up and smp2 variants are defined somewhere further down the config file.
It might make more sense to add no autotest.npb to the up variant,
which means this test will only run in an SMP configuration.
Otherwise, in the SMP variant extra_params will be  -smp 2 -smp 2.

  
  - linux_s3: install setup
  type = linux_s3
 diff --git a/client/tests/npb/control b/client/tests/npb/control
 new file mode 100644
 index 000..d6c2adb
 --- /dev/null
 +++ b/client/tests/npb/control
 @@ -0,0 +1,28 @@
 +NAME = NAS Parallel Benchmarks
 +AUTHOR = Cao, Chen k...@redhat.com
 +TEST_TYPE = CLIENT
 +TEST_CLASS = HARDWARE
 +TEST_CATEGORY = BENCHMARK
 +TIME = MEDIUM
 +DOC = \
 +Using NPB, OpenMP implementation.
 +
 +See http://www.nas.nasa.gov/Software/NPB/
 +
 +
 +# Supported tests (benchmarks):
 +#   bt.A bt.B bt.C bt.D bt.E bt.S bt.W
 +#   cg.A cg.B cg.C cg.S cg.W
 +#   dc.A dc.B dc.S dc.W
 +#   ep.A ep.B ep.C ep.D ep.E ep.S ep.W
 +#   ft.A ft.B ft.S ft.W
 +#   is.A is.B is.C is.S is.W
 +#   lu.A lu.B lu.C lu.S lu.W
 +#   mg.A mg.B mg.S mg.W
 +#   sp.A sp.B sp.C sp.D sp.E sp.S sp.W
 +#   ua.A ua.B ua.C ua.S ua.W
 +#
 +# Please refer to npb.py for more infomation about
 +# the arguments.
 +job.run_test(url='npb', tests='ep.A ep.B', ratio=0.5)
 +
 diff --git a/client/tests/npb/enable-all-tests.patch
 b/client/tests/npb/enable-all-tests.patch
 new file mode 100644
 index 000..f08a9d3
 --- /dev/null
 +++ b/client/tests/npb/enable-all-tests.patch
 @@ -0,0 +1,233 @@
 +diff --git a/NPB3.3-OMP/config/make.def b/NPB3.3-OMP/config/make.def
 +new file mode 100644
 +index 000..afffe7d
 +--- /dev/null
  b/NPB3.3-OMP/config/make.def
 +@@ -0,0 +1,161 @@
 ++#---
 ++#
 ++#SITE- AND/OR PLATFORM-SPECIFIC DEFINITIONS. 
 ++#
 ++#---
 ++
 ++#---
 ++# Items in this file will need to be changed for each platform.
 ++#---
 ++
 ++#---
 ++# Parallel Fortran:
 ++#
 ++# For CG, EP, FT, MG, LU, SP, BT and UA, which are in Fortran, the
 following 
 ++# must be defined:
 ++#
 ++# F77- Fortran compiler
 ++# FFLAGS - Fortran compilation arguments
 ++# F_INC  - any -I arguments required for compiling Fortran 
 ++# FLINK  - Fortran linker
 ++# FLINKFLAGS - Fortran linker arguments
 ++# F_LIB  - any -L and -l arguments required for linking Fortran
 
 ++# 
 ++# compilations are done with $(F77) $(F_INC) $(FFLAGS) or
 ++#$(F77) $(FFLAGS)
 ++# linking is done with   $(FLINK) $(F_LIB) $(FLINKFLAGS)
 ++#---
 ++
 ++#---
 ++# This is the fortran compiler used for Fortran programs
 ++#---
 ++F77 = gfortran
 ++# This links fortran programs; usually the same as ${F77}
 ++FLINK   = $(F77)
 ++
 ++#---
 ++# These macros are passed to the linker 
 ++#---
 ++F_LIB  =
 ++
 ++#---
 ++# These macros are passed to the compiler 
 ++#---
 ++F_INC =
 ++
 ++#---
 ++# Global *compile time* flags for Fortran programs
 

Re: [PATCH -v4] QEMU-KVM: MCE: Relay UCR MCE to guest

2009-09-21 Thread Avi Kivity

On 09/21/2009 05:43 AM, Huang Ying wrote:

UCR (uncorrected recovery) MCE is supported in recent Intel CPUs,
where some hardware error such as some memory error can be reported
without PCC (processor context corrupted). To recover from such MCE,
the corresponding memory will be unmapped, and all processes accessing
the memory will be killed via SIGBUS.

For KVM, if QEMU/KVM is killed, all guest processes will be killed
too. So we relay SIGBUS from host OS to guest system via a UCR MCE
injection. Then guest OS can isolate corresponding memory and kill
necessary guest processes only. SIGBUS sent to main thread (not VCPU
threads) will be broadcast to all VCPU threads as UCR MCE.

   


Applied, thanks.

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

--
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/2] make --disable-kvm to compile again

2009-09-21 Thread Avi Kivity

On 09/19/2009 03:59 PM, Juan Quintela wrote:

There were a couple of missing #ifdef KVM_* from last merge.
./configure --disable-kvm compiles and boots again.

It compiles, it boot, it is perfect!!! (*)

   


Applied, thanks.

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

--
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] qemu-kvm: Cleanup compatfd makefile rule

2009-09-21 Thread Avi Kivity

On 09/18/2009 08:31 PM, Jan Kiszka wrote:

Signed-off-by: Jan Kiszkajan.kis...@siemens.com
---

  Makefile |7 +--
  1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 6a9ca7c..6855fa2 100644
--- a/Makefile
+++ b/Makefile
@@ -65,9 +65,8 @@ recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)

  block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
  block-obj-y += nbd.o block.o aio.o aes.o osdep.o
-block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
+block-obj-$(CONFIG_POSIX) += posix-aio-compat.o compatfd.o
  block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
-block-obj-y += compatfd.o
   


This looks to be already obsolete, but note that I prefer kvm-specific 
changes to be on their own lines to reduce merge conflicts.  That is how 
the code look now.


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

--
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 23/24] Get CONFIG_CPU_EMULATION back to life

2009-09-21 Thread Juan Quintela
Avi Kivity a...@redhat.com wrote:
 On 09/19/2009 12:44 AM, Juan Quintela wrote:
 Marcelo Tosattimtosa...@redhat.com  wrote:

 On Fri, Sep 18, 2009 at 01:41:34PM +0200, Juan Quintela wrote:
  
 Code compile with --disable-cpu-emulation, and that don't compile
 tcg.  This is the minimal set of changes to get it working

 Better see this upstreamed (and perhaps remove support from qemu-kvm,
 unless someone disagrees).
  
 I am told it is needed for ia64 support.  But as ia64 port is not being
 too active, it don't matter too much.


 Applied, but can you look at upstreaming this?  Thanks.

Yeap, but upstream would not agree with this half-done implementation.
Will took at upstreaming the proper fix, but it will take a while.

Later, Juan.
--
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 04/24] piix4_dev is not used for pc's

2009-09-21 Thread Juan Quintela
Avi Kivity a...@redhat.com wrote:
 On 09/19/2009 12:42 AM, Juan Quintela wrote:

 Not applying because its dead code with the current state of pc.c
 configuration but this prevents one to use piix4.
  
 piix4 is not used for pci irq assignement in pc.  It is only used on
 mips.  I am the one that split the file in qemu upstream.  piix4 and
 piix3 are the same from the irq point of view.

 next pc chipset is not going to be piix4 :)


 I agree with Marcelo - even if mips never gains device assignment or
 pc never uses piix4, the code is more complete the way it is.

Ok, it forces to compile back piix4.o in a pc.  In qemu upstream piix4.o
is only compiled for MIPS.  That is the reason why I noticed. (Yes, I am
the one that did the split).

Later, Juan.
--
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 04/24] piix4_dev is not used for pc's

2009-09-21 Thread Avi Kivity

On 09/21/2009 12:37 PM, Juan Quintela wrote:

Avi Kivitya...@redhat.com  wrote:
   

On 09/19/2009 12:42 AM, Juan Quintela wrote:
 
   

Not applying because its dead code with the current state of pc.c
configuration but this prevents one to use piix4.

 

piix4 is not used for pci irq assignement in pc.  It is only used on
mips.  I am the one that split the file in qemu upstream.  piix4 and
piix3 are the same from the irq point of view.

next pc chipset is not going to be piix4 :)

   

I agree with Marcelo - even if mips never gains device assignment or
pc never uses piix4, the code is more complete the way it is.
 

Ok, it forces to compile back piix4.o in a pc.  In qemu upstream piix4.o
is only compiled for MIPS.  That is the reason why I noticed. (Yes, I am
the one that did the split).
   


Ah, in that case it's better to apply the patch.  Thanks.

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

--
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: [Autotest] [KVM-AUTOTEST PATCH 2/4] KVM test: rss.cpp: send characters to the console window rather than directly to STDIN

2009-09-21 Thread Yolkfull Chow
On Sun, Sep 20, 2009 at 06:16:28PM +0300, Michael Goldish wrote:
 Some Windows programs behave badly when their STDIN is redirected to a pipe
 (most notably wmic).  Therefore, keep STDIN unredirected, and send input to 
 the
 console window as a series of WM_CHAR messages.

Hi Michael, I just tried this patch. After re-compiling and
installing RSS, seems never a command could be executed successfully or
returned with results. I tested this on Win2008-32. Any clue for 
fixing up it?

 
 Signed-off-by: Michael Goldish mgold...@redhat.com
 ---
  client/tests/kvm/deps/rss.cpp |   54 +---
  1 files changed, 23 insertions(+), 31 deletions(-)
 
 diff --git a/client/tests/kvm/deps/rss.cpp b/client/tests/kvm/deps/rss.cpp
 index 73a849a..66d9a5b 100644
 --- a/client/tests/kvm/deps/rss.cpp
 +++ b/client/tests/kvm/deps/rss.cpp
 @@ -22,9 +22,9 @@ struct client_info {
  SOCKET socket;
  sockaddr_in addr;
  int pid;
 +HWND hwnd;
  HANDLE hJob;
  HANDLE hChildOutputRead;
 -HANDLE hChildInputWrite;
  HANDLE hThreadChildToSocket;
  };
  
 @@ -161,15 +161,10 @@ DWORD WINAPI SocketToChild(LPVOID client_info_ptr)
  sprintf(message, Client (%s) entered text: \%s\\r\n,
  client_info_str, formatted_buffer);
  AppendMessage(message);
 -// Write the data to the child's STDIN
 -WriteFile(ci.hChildInputWrite, buffer, bytes_received,
 -  bytes_written, NULL);
 -// Make sure all the data was written
 -if (bytes_written != bytes_received) {
 -sprintf(message,
 -SocketToChild: bytes received (%d) != bytes written 
 (%d),
 -bytes_received, bytes_written);
 -ExitOnError(message, 1);
 +// Send the data as a series of WM_CHAR messages to the console 
 window
 +for (int i=0; ibytes_received; i++) {
 +SendMessage(ci.hwnd, WM_CHAR, (WPARAM)buffer[i], 0);
 +SendMessage(ci.hwnd, WM_SETFOCUS, 0, 0);
  }
  }
  
 @@ -194,7 +189,6 @@ DWORD WINAPI SocketToChild(LPVOID client_info_ptr)
  CloseHandle(ci.hJob);
  CloseHandle(ci.hThreadChildToSocket);
  CloseHandle(ci.hChildOutputRead);
 -CloseHandle(ci.hChildInputWrite);
  
  AppendMessage(SocketToChild thread exited\r\n);
  
 @@ -203,18 +197,25 @@ DWORD WINAPI SocketToChild(LPVOID client_info_ptr)
  
  void PrepAndLaunchRedirectedChild(client_info *ci,
HANDLE hChildStdOut,
 -  HANDLE hChildStdIn,
HANDLE hChildStdErr)
  {
  PROCESS_INFORMATION pi;
  STARTUPINFO si;
  
 +// Allocate a new console for the child
 +HWND hwnd = GetForegroundWindow();
 +FreeConsole();
 +AllocConsole();
 +ShowWindow(GetConsoleWindow(), SW_HIDE);
 +if (hwnd)
 +SetForegroundWindow(hwnd);
 +
  // Set up the start up info struct.
  ZeroMemory(si, sizeof(STARTUPINFO));
  si.cb = sizeof(STARTUPINFO);
  si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
  si.hStdOutput = hChildStdOut;
 -si.hStdInput  = hChildStdIn;
 +si.hStdInput  = GetStdHandle(STD_INPUT_HANDLE);
  si.hStdError  = hChildStdErr;
  // Use this if you want to hide the child:
  si.wShowWindow = SW_HIDE;
 @@ -223,7 +224,7 @@ void PrepAndLaunchRedirectedChild(client_info *ci,
  
  // Launch the process that you want to redirect.
  if (!CreateProcess(NULL, cmd.exe, NULL, NULL, TRUE,
 -   CREATE_NEW_CONSOLE, NULL, C:\\, si, pi))
 +   0, NULL, C:\\, si, pi))
  ExitOnError(CreateProcess failed);
  
  // Close any unnecessary handles.
 @@ -235,12 +236,16 @@ void PrepAndLaunchRedirectedChild(client_info *ci,
  // Assign the process to a newly created JobObject
  ci-hJob = CreateJobObject(NULL, NULL);
  AssignProcessToJobObject(ci-hJob, pi.hProcess);
 +// Keep the console window's handle
 +ci-hwnd = GetConsoleWindow();
 +
 +// Detach from the child's console
 +FreeConsole();
  }
  
  void SpawnSession(client_info *ci)
  {
  HANDLE hOutputReadTmp, hOutputRead, hOutputWrite;
 -HANDLE hInputWriteTmp, hInputRead, hInputWrite;
  HANDLE hErrorWrite;
  SECURITY_ATTRIBUTES sa;
  
 @@ -261,10 +266,6 @@ void SpawnSession(client_info *ci)
   TRUE, DUPLICATE_SAME_ACCESS))
  ExitOnError(DuplicateHandle failed);
  
 -// Create the child input pipe.
 -if (!CreatePipe(hInputRead, hInputWriteTmp, sa, 0))
 -ExitOnError(CreatePipe failed);
 -
  // Create new output read handle and the input write handles. Set
  // the Properties to FALSE. Otherwise, the child inherits the
  // properties and, as a result, non-closeable handles to the pipes
 @@ -276,29 +277,20 @@ void SpawnSession(client_info *ci)
   DUPLICATE_SAME_ACCESS))
  

buildbot failure in qemu-kvm on default_x86_64_out_of_tree

2009-09-21 Thread qemu-kvm
The Buildbot has detected a new failure of default_x86_64_out_of_tree on 
qemu-kvm.
Full details are available at:
 
http://buildbot.b1-systems.de/qemu-kvm/builders/default_x86_64_out_of_tree/builds/14

Buildbot URL: http://buildbot.b1-systems.de/qemu-kvm/

Buildslave for this Build: b1_qemu_kvm_1

Build Reason: 
Build Source Stamp: [branch master] HEAD
Blamelist: Anthony Liguori aligu...@us.ibm.com,Aurelien Jarno 
aurel...@aurel32.net,Avi Kivity a...@redhat.com,Blue Swirl 
blauwir...@gmail.com,Christoph Hellwig h...@lst.de,Daniel Jacobowitz 
d...@false.org,Dustin Kirkland kirkl...@canonical.com,Edgar E. Iglesias 
edgar.igles...@gmail.com,Gerd Hoffmann kra...@redhat.com,Gleb Natapov 
g...@redhat.com,Huang Ying ying.hu...@intel.com,Jan Kiszka 
jan.kis...@siemens.com,Jan Kiszka jan.kis...@web.de,Jim Paris 
j...@jtan.com,Juan Quintela quint...@redhat.com,Kevin Wolf 
kw...@redhat.com,Kirill A. Shutemov kir...@shutemov.name,Marcelo Tosatti 
mtosa...@redhat.com,Markus Armbruster arm...@redhat.com,Michael S. Tsirkin 
m...@redhat.com,Reimar Döffinger reimar.doeffin...@gmx.de,Sebastian 
Herbszt herb...@gmx.de,Stefan Weil w...@mail.berlios.de,Yan Vugenfirer 
yvuge...@redhat.com,malc av1...@comtv.ru

BUILD FAILED: failed git

sincerely,
 -The Buildbot

--
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


buildbot failure in qemu-kvm on default_i386_out_of_tree

2009-09-21 Thread qemu-kvm
The Buildbot has detected a new failure of default_i386_out_of_tree on qemu-kvm.
Full details are available at:
 
http://buildbot.b1-systems.de/qemu-kvm/builders/default_i386_out_of_tree/builds/12

Buildbot URL: http://buildbot.b1-systems.de/qemu-kvm/

Buildslave for this Build: b1_qemu_kvm_2

Build Reason: 
Build Source Stamp: [branch master] HEAD
Blamelist: Anthony Liguori aligu...@us.ibm.com,Aurelien Jarno 
aurel...@aurel32.net,Avi Kivity a...@redhat.com,Blue Swirl 
blauwir...@gmail.com,Christoph Hellwig h...@lst.de,Daniel Jacobowitz 
d...@false.org,Dustin Kirkland kirkl...@canonical.com,Edgar E. Iglesias 
edgar.igles...@gmail.com,Gerd Hoffmann kra...@redhat.com,Gleb Natapov 
g...@redhat.com,Huang Ying ying.hu...@intel.com,Jan Kiszka 
jan.kis...@siemens.com,Jan Kiszka jan.kis...@web.de,Jim Paris 
j...@jtan.com,Juan Quintela quint...@redhat.com,Kevin Wolf 
kw...@redhat.com,Kirill A. Shutemov kir...@shutemov.name,Marcelo Tosatti 
mtosa...@redhat.com,Markus Armbruster arm...@redhat.com,Michael S. Tsirkin 
m...@redhat.com,Reimar Döffinger reimar.doeffin...@gmx.de,Sebastian 
Herbszt herb...@gmx.de,Stefan Weil w...@mail.berlios.de,Yan Vugenfirer 
yvuge...@redhat.com,malc av1...@comtv.ru

BUILD FAILED: failed git

sincerely,
 -The Buildbot

--
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


buildbot failure in qemu-kvm on default_i386_debian_5_0

2009-09-21 Thread qemu-kvm
The Buildbot has detected a new failure of default_i386_debian_5_0 on qemu-kvm.
Full details are available at:
 
http://buildbot.b1-systems.de/qemu-kvm/builders/default_i386_debian_5_0/builds/75

Buildbot URL: http://buildbot.b1-systems.de/qemu-kvm/

Buildslave for this Build: b1_qemu_kvm_2

Build Reason: 
Build Source Stamp: [branch master] HEAD
Blamelist: Anthony Liguori aligu...@us.ibm.com,Aurelien Jarno 
aurel...@aurel32.net,Avi Kivity a...@redhat.com,Blue Swirl 
blauwir...@gmail.com,Christoph Hellwig h...@lst.de,Daniel Jacobowitz 
d...@false.org,Dustin Kirkland kirkl...@canonical.com,Edgar E. Iglesias 
edgar.igles...@gmail.com,Gerd Hoffmann kra...@redhat.com,Gleb Natapov 
g...@redhat.com,Huang Ying ying.hu...@intel.com,Jan Kiszka 
jan.kis...@siemens.com,Jan Kiszka jan.kis...@web.de,Jim Paris 
j...@jtan.com,Juan Quintela quint...@redhat.com,Kevin Wolf 
kw...@redhat.com,Kirill A. Shutemov kir...@shutemov.name,Marcelo Tosatti 
mtosa...@redhat.com,Markus Armbruster arm...@redhat.com,Michael S. Tsirkin 
m...@redhat.com,Reimar Döffinger reimar.doeffin...@gmx.de,Sebastian 
Herbszt herb...@gmx.de,Stefan Weil w...@mail.berlios.de,Yan Vugenfirer 
yvuge...@redhat.com,malc av1...@comtv.ru

BUILD FAILED: failed compile

sincerely,
 -The Buildbot

--
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


buildbot failure in qemu-kvm on default_x86_64_debian_5_0

2009-09-21 Thread qemu-kvm
The Buildbot has detected a new failure of default_x86_64_debian_5_0 on 
qemu-kvm.
Full details are available at:
 
http://buildbot.b1-systems.de/qemu-kvm/builders/default_x86_64_debian_5_0/builds/73

Buildbot URL: http://buildbot.b1-systems.de/qemu-kvm/

Buildslave for this Build: b1_qemu_kvm_1

Build Reason: 
Build Source Stamp: [branch master] HEAD
Blamelist: Anthony Liguori aligu...@us.ibm.com,Aurelien Jarno 
aurel...@aurel32.net,Avi Kivity a...@redhat.com,Blue Swirl 
blauwir...@gmail.com,Christoph Hellwig h...@lst.de,Daniel Jacobowitz 
d...@false.org,Dustin Kirkland kirkl...@canonical.com,Edgar E. Iglesias 
edgar.igles...@gmail.com,Gerd Hoffmann kra...@redhat.com,Gleb Natapov 
g...@redhat.com,Huang Ying ying.hu...@intel.com,Jan Kiszka 
jan.kis...@siemens.com,Jan Kiszka jan.kis...@web.de,Jim Paris 
j...@jtan.com,Juan Quintela quint...@redhat.com,Kevin Wolf 
kw...@redhat.com,Kirill A. Shutemov kir...@shutemov.name,Marcelo Tosatti 
mtosa...@redhat.com,Markus Armbruster arm...@redhat.com,Michael S. Tsirkin 
m...@redhat.com,Reimar Döffinger reimar.doeffin...@gmx.de,Sebastian 
Herbszt herb...@gmx.de,Stefan Weil w...@mail.berlios.de,Yan Vugenfirer 
yvuge...@redhat.com,malc av1...@comtv.ru

BUILD FAILED: failed compile

sincerely,
 -The Buildbot

--
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] Adding NAS Parallel Benchmarks(NPB) as client test [1/2] V2

2009-09-21 Thread Cao, Chen
- Using NPB OpenMP implementaion.

Changes from the original patch:
Remove the variant 'extra_params += smp 2', and add a restriction
(no autotest.npb) under variant 'up', according to mgoldish's advice.
Nevertheless, user can run this test with smp=1, if he/she wants to.

Signed-off-by: Cao, Chen k...@redhat.com
---
 client/tests/kvm/kvm_tests.cfg.sample   |4 +
 client/tests/npb/control|   28 
 client/tests/npb/enable-all-tests.patch |  233 +++
 client/tests/npb/npb.py |   95 +
 4 files changed, 360 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/npb/control
 create mode 100644 client/tests/npb/enable-all-tests.patch
 create mode 100644 client/tests/npb/npb.py

diff --git a/client/tests/kvm/kvm_tests.cfg.sample 
b/client/tests/kvm/kvm_tests.cfg.sample
index 285a38f..b03b7cd 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -90,6 +90,9 @@ variants:
 - disktest:
 test_name = disktest
 test_control_file = disktest.control
+- npb:
+test_name = npb
+test_control_file = npb.control
 
 - linux_s3: install setup
 type = linux_s3
@@ -567,6 +570,7 @@ linux_s3:
 
 variants:
 - @up:
+no autotest.npb
 - smp2:
 extra_params +=  -smp 2
 
diff --git a/client/tests/npb/control b/client/tests/npb/control
new file mode 100644
index 000..d6c2adb
--- /dev/null
+++ b/client/tests/npb/control
@@ -0,0 +1,28 @@
+NAME = NAS Parallel Benchmarks
+AUTHOR = Cao, Chen k...@redhat.com
+TEST_TYPE = CLIENT
+TEST_CLASS = HARDWARE
+TEST_CATEGORY = BENCHMARK
+TIME = MEDIUM
+DOC = \
+Using NPB, OpenMP implementation.
+
+See http://www.nas.nasa.gov/Software/NPB/
+
+
+# Supported tests (benchmarks):
+#   bt.A bt.B bt.C bt.D bt.E bt.S bt.W
+#   cg.A cg.B cg.C cg.S cg.W
+#   dc.A dc.B dc.S dc.W
+#   ep.A ep.B ep.C ep.D ep.E ep.S ep.W
+#   ft.A ft.B ft.S ft.W
+#   is.A is.B is.C is.S is.W
+#   lu.A lu.B lu.C lu.S lu.W
+#   mg.A mg.B mg.S mg.W
+#   sp.A sp.B sp.C sp.D sp.E sp.S sp.W
+#   ua.A ua.B ua.C ua.S ua.W
+#
+# Please refer to npb.py for more infomation about
+# the arguments.
+job.run_test(url='npb', tests='ep.A ep.B', ratio=0.5)
+
diff --git a/client/tests/npb/enable-all-tests.patch 
b/client/tests/npb/enable-all-tests.patch
new file mode 100644
index 000..f08a9d3
--- /dev/null
+++ b/client/tests/npb/enable-all-tests.patch
@@ -0,0 +1,233 @@
+diff --git a/NPB3.3-OMP/config/make.def b/NPB3.3-OMP/config/make.def
+new file mode 100644
+index 000..afffe7d
+--- /dev/null
 b/NPB3.3-OMP/config/make.def
+@@ -0,0 +1,161 @@
++#---
++#
++#SITE- AND/OR PLATFORM-SPECIFIC DEFINITIONS. 
++#
++#---
++
++#---
++# Items in this file will need to be changed for each platform.
++#---
++
++#---
++# Parallel Fortran:
++#
++# For CG, EP, FT, MG, LU, SP, BT and UA, which are in Fortran, the following 
++# must be defined:
++#
++# F77- Fortran compiler
++# FFLAGS - Fortran compilation arguments
++# F_INC  - any -I arguments required for compiling Fortran 
++# FLINK  - Fortran linker
++# FLINKFLAGS - Fortran linker arguments
++# F_LIB  - any -L and -l arguments required for linking Fortran 
++# 
++# compilations are done with $(F77) $(F_INC) $(FFLAGS) or
++#$(F77) $(FFLAGS)
++# linking is done with   $(FLINK) $(F_LIB) $(FLINKFLAGS)
++#---
++
++#---
++# This is the fortran compiler used for Fortran programs
++#---
++F77 = gfortran
++# This links fortran programs; usually the same as ${F77}
++FLINK = $(F77)
++
++#---
++# These macros are passed to the linker 
++#---
++F_LIB  =
++
++#---
++# These macros are passed to the compiler 
++#---
++F_INC =
++
++#---
++# Global *compile time* flags for Fortran programs
++#---
++FFLAGS= -O -fopenmp 
++
++#---

Differences on Intel and Amd

2009-09-21 Thread Alpár Török
Hi all,

Sorry if this issues, or parts of this issue have been covered in
separate threads.

We  have an executable, of unknown origin, that is very likely to be
malicious.  We use KVM ( version 78) for sand-boxing the execution of
such software.
Each time the Virtual Machine is started from  a snapshot (with loadvm
), an executable is copied from a share and launched.

Now the problem. We have both AMD and Intel  machines. A snapshot
taken on Intel doesn't load on AMD and vice versa, so The snapshots
from which the VMs are
started are different. This executable, runs on the AMD machines, but
not on Intel. We concluded that the executable uses an undocumented
Windows API
function, and relies on a side-effect (a value placed in a register).
The value of this register differs from AMD to Intel. That is why it
shortly and silently terminates if ran on Intel. (by ran on Intel and
ran on AMD i mean of course a KVM VM on those platforms)

The questions are:
 Can a process within the VM find out the native processor type?
 Or can Windows XP find out the original processor type and behave differently?
 Does this behavior make sense to you?
 Is it possible that the difference is not due to hardware
differences, but because of different snapshots, and the events that
 occur before the snapshots, are different?

 We need to have consistent and repeatable results with thease
sand-boxed tests, that was what triggered the investigation in the
first place.


--
Alpar Torok
--
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 -v4] QEMU-KVM: MCE: Relay UCR MCE to guest

2009-09-21 Thread Avi Kivity

On 09/21/2009 05:43 AM, Huang Ying wrote:

UCR (uncorrected recovery) MCE is supported in recent Intel CPUs,
where some hardware error such as some memory error can be reported
without PCC (processor context corrupted). To recover from such MCE,
the corresponding memory will be unmapped, and all processes accessing
the memory will be killed via SIGBUS.

For KVM, if QEMU/KVM is killed, all guest processes will be killed
too. So we relay SIGBUS from host OS to guest system via a UCR MCE
injection. Then guest OS can isolate corresponding memory and kill
necessary guest processes only. SIGBUS sent to main thread (not VCPU
threads) will be broadcast to all VCPU threads as UCR MCE.



--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -27,10 +27,23 @@
  #includesys/mman.h
  #includesys/ioctl.h
  #includesignal.h
+#includesys/signalfd.h
   


This causes a build failure, since not all hosts have sys/signalfd.h, 
but more importantly:



+
+static void sigbus_handler(int n, struct signalfd_siginfo *siginfo, void *ctx)
+{
   


Here you accept signalfd_siginfo, while


+
+memset(action, 0, sizeof(action));
+action.sa_flags = SA_SIGINFO;
+action.sa_sigaction = (void (*)(int, siginfo_t*, void*))sigbus_handler;
+sigaction(SIGBUS,action, NULL);
+prctl(PR_MCE_KILL, 1, 1);
  return 0;
   


here you arm the function with something that will send it a siginfo_t.  
So it looks like this is broken if a signal is ever received directly?  
But can this happen due to signalfd?



  }

@@ -1962,7 +2116,10 @@ static void sigfd_handler(void *opaque)
  }

  sigaction(info.ssi_signo, NULL,action);
-if (action.sa_handler)
+if ((action.sa_flags  SA_SIGINFO)  action.sa_sigaction)
+action.sa_sigaction(info.ssi_signo,
+(siginfo_t *)info, NULL);
+   else if (action.sa_handler)
  action.sa_handler(info.ssi_signo);
   


The whole extract handler from sigaction and call it was a hack.


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

--
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


  1   2   >