[COMMIT master] slirp: Fix default netmask to 255.255.255.0

2009-07-12 Thread Avi Kivity
From: Jan Kiszka jan.kis...@siemens.com

This got broken between a13a4126c8 and c92ef6a22d: old slirp code used
255.255.255.0.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/net.c b/net.c
index 19e00e0..a34f1d3 100644
--- a/net.c
+++ b/net.c
@@ -802,8 +802,8 @@ static int net_slirp_init(Monitor *mon, VLANState *vlan, 
const char *model,
   const char *vsmbserver)
 {
 /* default settings according to historic slirp */
-struct in_addr net  = { .s_addr = htonl(0x0a00) }; /* 10.0.0.0 */
-struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.0.0.0 */
+struct in_addr net  = { .s_addr = htonl(0x0a000200) }; /* 10.0.2.0 */
+struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.255.255.0 */
 struct in_addr host = { .s_addr = htonl(0x0a000202) }; /* 10.0.2.2 */
 struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) }; /* 10.0.2.15 */
 struct in_addr dns  = { .s_addr = htonl(0x0a000203) }; /* 10.0.2.3 */
--
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] Revert support colon in filenames

2009-07-12 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

This reverts commit 707c0dbc97cddfe8d2441b8259c6c526d99f2dd8.   It was
reverted from upstream as well.

Conflicts:

block.c

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

diff --git a/block.c b/block.c
index ddd055c..cefbe77 100644
--- a/block.c
+++ b/block.c
@@ -225,7 +225,7 @@ static BlockDriver *find_protocol(const char *filename)
 {
 BlockDriver *drv1;
 char protocol[128];
-int len = qemu_strnlen(filename, 127) + 1;
+int len;
 const char *p;
 
 #ifdef _WIN32
@@ -233,9 +233,14 @@ static BlockDriver *find_protocol(const char *filename)
 is_windows_drive_prefix(filename))
 return bdrv_find_format(raw);
 #endif
-p = fill_token(protocol, len, filename, ':');
-if (*p != ':')
+p = strchr(filename, ':');
+if (!p)
 return bdrv_find_format(raw);
+len = p - filename;
+if (len  sizeof(protocol) - 1)
+len = sizeof(protocol) - 1;
+memcpy(protocol, filename, len);
+protocol[len] = '\0';
 for(drv1 = first_drv; drv1 != NULL; drv1 = drv1-next) {
 if (drv1-protocol_name 
 !strcmp(drv1-protocol_name, protocol))
@@ -409,9 +414,9 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, 
int flags,
 open_flags = BDRV_O_RDWR | (flags  BDRV_O_CACHE_MASK);
 else
 open_flags = flags  ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
-ret = bdrv_open3(bs, filename, open_flags, drv);
+ret = drv-bdrv_open(bs, filename, open_flags);
 if ((ret == -EACCES || ret == -EPERM)  !(flags  BDRV_O_FILE)) {
-ret = bdrv_open3(bs, filename, open_flags  ~BDRV_O_RDWR, drv);
+ret = drv-bdrv_open(bs, filename, open_flags  ~BDRV_O_RDWR);
 bs-read_only = 1;
 }
 if (ret  0) {
@@ -456,18 +461,6 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, 
int flags,
 return 0;
 }
 
-int bdrv_open3(BlockDriverState *bs, const char *filename, int flags, 
BlockDriver *drv)
-{
-char myfile[PATH_MAX];
-const char *f;
-
-if (!strstart(filename, file:, f)) {
-fill_token(myfile, PATH_MAX, filename, '\0');
-return drv-bdrv_open(bs,myfile,flags);
-}
-return drv-bdrv_open(bs,f,flags);
-}
-
 void bdrv_close(BlockDriverState *bs)
 {
 if (bs-drv) {
diff --git a/block.h b/block.h
index b595772..71e87fc 100644
--- a/block.h
+++ b/block.h
@@ -58,8 +58,6 @@ int bdrv_file_open(BlockDriverState **pbs, const char 
*filename, int flags);
 int bdrv_open(BlockDriverState *bs, const char *filename, int flags);
 int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
BlockDriver *drv);
-int bdrv_open3(BlockDriverState *bs, const char *filename, int flags,
-   BlockDriver *drv);
 void bdrv_close(BlockDriverState *bs);
 int bdrv_check(BlockDriverState *bs);
 int bdrv_read(BlockDriverState *bs, int64_t sector_num,
diff --git a/block/dmg.c b/block/dmg.c
index dd98af4..262560f 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -94,7 +94,7 @@ dmg_close:
close(s-fd);
/* open raw instead */
bs-drv=bdrv_find_format(raw);
-   return bdrv_open3(bs, filename, flags, bs-drv);
+   return bs-drv-bdrv_open(bs, filename, flags);
 }
 info_begin=read_off(s-fd);
 if(info_begin==0)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index c578814..51c4dfb 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -901,7 +901,6 @@ static BlockDriver bdrv_raw = {
 .bdrv_getlength = raw_getlength,
 
 .create_options = raw_create_options,
-.protocol_name = file,
 };
 
 /***/
diff --git a/cutils.c b/cutils.c
index 346477b..c8d5326 100644
--- a/cutils.c
+++ b/cutils.c
@@ -24,32 +24,6 @@
 #include qemu-common.h
 #include host-utils.h
 
-/*
- * fill first 'len' characters of 'buff' with pruned
- * contents of 'str' delimited by the character 'c'.
- * Escape character '\' is pruned off.
- * Return pointer to the delimiting character.
- */
-const char *fill_token(char *buf, const int len, const char *str, const char c)
-{
-const char *p=str;
-char *q=buf;
-
-while (p  str+len-1) {
-if (*p == c)
-break;
-if (*p == '\\') {
-p++;
-if (*p == '\0')
-break;
-}
-*q++ = *p++;
-}
-*q='\0';
-return p;
-}
-
-
 void pstrcpy(char *buf, int buf_size, const char *str)
 {
 int c;
diff --git a/qemu-common.h b/qemu-common.h
index 53ff1d6..d478b47 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -104,7 +104,6 @@ void qemu_get_timedate(struct tm *tm, int offset);
 int qemu_timedate_diff(struct tm *tm);
 
 /* cutils.c */
-const char *fill_token(char *buf, int buf_size, const char *str, char);
 void pstrcpy(char *buf, int buf_size, const char *str);
 char *pstrcat(char *buf, int buf_size, const char *s);
 int strstart(const char *str, const char *val, const char **ptr);
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body 

[COMMIT master] slirp: Fix default netmask to 255.255.255.0

2009-07-12 Thread Avi Kivity
From: Jan Kiszka jan.kis...@siemens.com

This got broken between a13a4126c8 and c92ef6a22d: old slirp code used
255.255.255.0.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/net.c b/net.c
index 19e00e0..a34f1d3 100644
--- a/net.c
+++ b/net.c
@@ -802,8 +802,8 @@ static int net_slirp_init(Monitor *mon, VLANState *vlan, 
const char *model,
   const char *vsmbserver)
 {
 /* default settings according to historic slirp */
-struct in_addr net  = { .s_addr = htonl(0x0a00) }; /* 10.0.0.0 */
-struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.0.0.0 */
+struct in_addr net  = { .s_addr = htonl(0x0a000200) }; /* 10.0.2.0 */
+struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.255.255.0 */
 struct in_addr host = { .s_addr = htonl(0x0a000202) }; /* 10.0.2.2 */
 struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) }; /* 10.0.2.15 */
 struct in_addr dns  = { .s_addr = htonl(0x0a000203) }; /* 10.0.2.3 */
--
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] slirp: Fix default netmask to 255.255.255.0

2009-07-12 Thread Avi Kivity
From: Jan Kiszka jan.kis...@siemens.com

This got broken between a13a4126c8 and c92ef6a22d: old slirp code used
255.255.255.0.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/net.c b/net.c
index 19e00e0..a34f1d3 100644
--- a/net.c
+++ b/net.c
@@ -802,8 +802,8 @@ static int net_slirp_init(Monitor *mon, VLANState *vlan, 
const char *model,
   const char *vsmbserver)
 {
 /* default settings according to historic slirp */
-struct in_addr net  = { .s_addr = htonl(0x0a00) }; /* 10.0.0.0 */
-struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.0.0.0 */
+struct in_addr net  = { .s_addr = htonl(0x0a000200) }; /* 10.0.2.0 */
+struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.255.255.0 */
 struct in_addr host = { .s_addr = htonl(0x0a000202) }; /* 10.0.2.2 */
 struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) }; /* 10.0.2.15 */
 struct in_addr dns  = { .s_addr = htonl(0x0a000203) }; /* 10.0.2.3 */
--
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] slirp: Fix default netmask to 255.255.255.0

2009-07-12 Thread Avi Kivity
From: Jan Kiszka jan.kis...@siemens.com

This got broken between a13a4126c8 and c92ef6a22d: old slirp code used
255.255.255.0.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/net.c b/net.c
index 19e00e0..a34f1d3 100644
--- a/net.c
+++ b/net.c
@@ -802,8 +802,8 @@ static int net_slirp_init(Monitor *mon, VLANState *vlan, 
const char *model,
   const char *vsmbserver)
 {
 /* default settings according to historic slirp */
-struct in_addr net  = { .s_addr = htonl(0x0a00) }; /* 10.0.0.0 */
-struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.0.0.0 */
+struct in_addr net  = { .s_addr = htonl(0x0a000200) }; /* 10.0.2.0 */
+struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.255.255.0 */
 struct in_addr host = { .s_addr = htonl(0x0a000202) }; /* 10.0.2.2 */
 struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) }; /* 10.0.2.15 */
 struct in_addr dns  = { .s_addr = htonl(0x0a000203) }; /* 10.0.2.3 */
--
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] slirp: Fix default netmask to 255.255.255.0

2009-07-12 Thread Avi Kivity
From: Jan Kiszka jan.kis...@siemens.com

This got broken between a13a4126c8 and c92ef6a22d: old slirp code used
255.255.255.0.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/net.c b/net.c
index 19e00e0..a34f1d3 100644
--- a/net.c
+++ b/net.c
@@ -802,8 +802,8 @@ static int net_slirp_init(Monitor *mon, VLANState *vlan, 
const char *model,
   const char *vsmbserver)
 {
 /* default settings according to historic slirp */
-struct in_addr net  = { .s_addr = htonl(0x0a00) }; /* 10.0.0.0 */
-struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.0.0.0 */
+struct in_addr net  = { .s_addr = htonl(0x0a000200) }; /* 10.0.2.0 */
+struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.255.255.0 */
 struct in_addr host = { .s_addr = htonl(0x0a000202) }; /* 10.0.2.2 */
 struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) }; /* 10.0.2.15 */
 struct in_addr dns  = { .s_addr = htonl(0x0a000203) }; /* 10.0.2.3 */
--
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] slirp: Fix default netmask to 255.255.255.0

2009-07-12 Thread Avi Kivity
From: Jan Kiszka jan.kis...@siemens.com

This got broken between a13a4126c8 and c92ef6a22d: old slirp code used
255.255.255.0.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/net.c b/net.c
index 19e00e0..a34f1d3 100644
--- a/net.c
+++ b/net.c
@@ -802,8 +802,8 @@ static int net_slirp_init(Monitor *mon, VLANState *vlan, 
const char *model,
   const char *vsmbserver)
 {
 /* default settings according to historic slirp */
-struct in_addr net  = { .s_addr = htonl(0x0a00) }; /* 10.0.0.0 */
-struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.0.0.0 */
+struct in_addr net  = { .s_addr = htonl(0x0a000200) }; /* 10.0.2.0 */
+struct in_addr mask = { .s_addr = htonl(0xff00) }; /* 255.255.255.0 */
 struct in_addr host = { .s_addr = htonl(0x0a000202) }; /* 10.0.2.2 */
 struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) }; /* 10.0.2.15 */
 struct in_addr dns  = { .s_addr = htonl(0x0a000203) }; /* 10.0.2.3 */
--
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] Select irq0-irq2 override based on kernel gsi routing availability

2009-07-12 Thread Avi Kivity
From: Beth Kon e...@us.ibm.com

If the kernel does not support gsi routing, we cannot do the irq0-irq2
override, so disable it in that case.

Signed-off-by: Beth Kon e...@us.ibm.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/hw/ioapic.c b/hw/ioapic.c
index 8a16a5b..efd418d 100644
--- a/hw/ioapic.c
+++ b/hw/ioapic.c
@@ -23,6 +23,7 @@
 
 #include hw.h
 #include pc.h
+#include sysemu.h
 #include qemu-timer.h
 #include host-utils.h
 
@@ -95,14 +96,13 @@ void ioapic_set_irq(void *opaque, int vector, int level)
 {
 IOAPICState *s = opaque;
 
-#if 0
 /* ISA IRQs map to GSI 1-1 except for IRQ0 which maps
  * to GSI 2.  GSI maps to ioapic 1-1.  This is not
  * the cleanest way of doing it but it should work. */
 
-if (vector == 0)
+if (vector == 0  irq0override) {
 vector = 2;
-#endif
+}
 
 if (vector = 0  vector  IOAPIC_NUM_PINS) {
 uint32_t mask = 1  vector;
diff --git a/hw/pc.c b/hw/pc.c
index afab0ad..ecc7046 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -58,6 +58,7 @@
 #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)
 
 #define MAX_IDE_BUS 2
 
@@ -480,6 +481,7 @@ static void *bochs_bios_init(void)
 fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
 fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES, (uint8_t *)acpi_tables,
  acpi_tables_len);
+fw_cfg_add_bytes(fw_cfg, FW_CFG_IRQ0_OVERRIDE, irq0override, 1);
 
 smbios_table = smbios_get_table(smbios_len);
 if (smbios_table)
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 8ba3b6e..67aca32 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1564,7 +1564,11 @@ int kvm_arch_init_irq_routing(void)
 return r;
 }
 for (i = 0; i  24; ++i) {
-r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_IOAPIC, i);
+if (i == 0) {
+r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_IOAPIC, 2);
+} else if (i != 2) {
+r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_IOAPIC, i);
+}
 if (r  0)
 return r;
 }
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 4c185fd..a490ddc 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -162,6 +162,7 @@ int kvm_has_sync_mmu(void);
 #define kvm_enabled() (kvm_allowed)
 #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context)
 #define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context)
+#define qemu_kvm_has_gsi_routing() kvm_has_gsi_routing(kvm_context)
 void kvm_init_vcpu(CPUState *env);
 void kvm_load_tsc(CPUState *env);
 #else
@@ -170,6 +171,7 @@ void kvm_load_tsc(CPUState *env);
 #define kvm_nested 0
 #define qemu_kvm_irqchip_in_kernel() (0)
 #define qemu_kvm_pit_in_kernel() (0)
+#define qemu_kvm_has_gsi_routing() (0)
 #define kvm_load_registers(env) do {} while(0)
 #define kvm_save_registers(env) do {} while(0)
 #define qemu_kvm_cpu_stop(env) do {} while(0)
diff --git a/sysemu.h b/sysemu.h
index 5582633..75ea191 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -111,6 +111,7 @@ extern int xenfb_enabled;
 extern int graphic_width;
 extern int graphic_height;
 extern int graphic_depth;
+extern uint8_t irq0override;
 extern DisplayType display_type;
 extern const char *keyboard_layout;
 extern int win2k_install_hack;
diff --git a/vl.c b/vl.c
index 5d86e69..c123358 100644
--- a/vl.c
+++ b/vl.c
@@ -254,6 +254,7 @@ int no_reboot = 0;
 int no_shutdown = 0;
 int cursor_hide = 1;
 int graphic_rotate = 0;
+uint8_t irq0override = 1;
 #ifndef _WIN32
 int daemonize = 0;
 #endif
@@ -6219,8 +6220,14 @@ int main(int argc, char **argv, char **envp)
 
 module_call_init(MODULE_INIT_DEVICE);
 
-if (kvm_enabled())
-   kvm_init_ap();
+if (kvm_enabled()) {
+   kvm_init_ap();
+#ifdef USE_KVM
+if (kvm_irqchip  !qemu_kvm_has_gsi_routing()) {
+irq0override = 0;
+}
+#endif
+}
 
 machine-init(ram_size, boot_devices,
   kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
--
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] bios: allow qemu to configure irq0-inti2 override

2009-07-12 Thread Avi Kivity
From: Beth Kon e...@us.ibm.com

Win2k8 expects the HPET interrupt on inti2, regardless of whether an
override exists in the BIOS. And the HPET spec states that in legacy
mode, timer interrupt is on inti2.

The irq0-inti2 override will always be used unless the kernel cannot
do irq routing (i.e., compatibility with old kernels). So if the
kernel is capable, userspace sets up irq0-inti2 via the irq routing
interface, and adds the irq0-inti2 override to the MADT interrupt
source override table, and the mp table (for the no-acpi case).

Signed-off-by: Beth Kon e...@us.ibm.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/kvm/bios/rombios32.c b/kvm/bios/rombios32.c
index 0369111..f9e0452 100755
--- a/kvm/bios/rombios32.c
+++ b/kvm/bios/rombios32.c
@@ -446,6 +446,9 @@ uint32_t cpuid_features;
 uint32_t cpuid_ext_features;
 unsigned long ram_size;
 uint64_t ram_end;
+#ifdef BX_QEMU
+uint8_t irq0_override;
+#endif
 #ifdef BX_USE_EBDA_TABLES
 unsigned long ebda_cur_addr;
 #endif
@@ -487,6 +490,7 @@ void wrmsr_smp(uint32_t index, uint64_t val)
 #define QEMU_CFG_ARCH_LOCAL 0x8000
 #define QEMU_CFG_ACPI_TABLES  (QEMU_CFG_ARCH_LOCAL + 0)
 #define QEMU_CFG_SMBIOS_ENTRIES  (QEMU_CFG_ARCH_LOCAL + 1)
+#define QEMU_CFG_IRQ0_OVERRIDE   (QEMU_CFG_ARCH_LOCAL + 2)
 
 int qemu_cfg_port;
 
@@ -555,6 +559,16 @@ uint64_t qemu_cfg_get64 (void)
 }
 #endif
 
+#ifdef BX_QEMU
+void irq0_override_probe(void)
+{
+if(qemu_cfg_port) {
+qemu_cfg_select(QEMU_CFG_IRQ0_OVERRIDE);
+qemu_cfg_read(irq0_override, 1);
+}
+}
+#endif
+
 void cpu_probe(void)
 {
 uint32_t eax, ebx, ecx, edx;
@@ -1153,7 +1167,14 @@ static void mptable_init(void)
 putstr(q, 0.1 ); /* vendor id */
 putle32(q, 0); /* OEM table ptr */
 putle16(q, 0); /* OEM table size */
+#ifdef BX_QEMU
+if (irq0_override)
+putle16(q, MAX_CPUS + 17); /* entry count */
+else
+putle16(q, MAX_CPUS + 18); /* entry count */
+#else
 putle16(q, MAX_CPUS + 18); /* entry count */
+#endif
 putle32(q, 0xfee0); /* local APIC addr */
 putle16(q, 0); /* ext table length */
 putb(q, 0); /* ext table checksum */
@@ -1197,6 +1218,13 @@ static void mptable_init(void)
 
 /* irqs */
 for(i = 0; i  16; i++) {
+#ifdef BX_QEMU
+/* One entry per ioapic interrupt destination. Destination 2 is covered
+ * by irq0-inti2 override (i == 0). Source IRQ 2 is unused
+ */
+if (irq0_override  i == 2)
+continue;
+#endif
 putb(q, 3); /* entry type = I/O interrupt */
 putb(q, 0); /* interrupt type = vectored interrupt */
 putb(q, 0); /* flags: po=0, el=0 */
@@ -1204,7 +1232,12 @@ static void mptable_init(void)
 putb(q, 0); /* source bus ID = ISA */
 putb(q, i); /* source bus IRQ */
 putb(q, ioapic_id); /* dest I/O APIC ID */
-putb(q, i); /* dest I/O APIC interrupt in */
+#ifdef BX_QEMU
+if (irq0_override  i == 0)
+putb(q, 2); /* dest I/O APIC interrupt in */
+else
+#endif
+putb(q, i); /* dest I/O APIC interrupt in */
 }
 /* patch length */
 len = q - mp_config_table;
@@ -1768,23 +1801,21 @@ void acpi_bios_init(void)
 io_apic-io_apic_id = smp_cpus;
 io_apic-address = cpu_to_le32(0xfec0);
 io_apic-interrupt = cpu_to_le32(0);
-#ifdef BX_QEMU
-#ifdef HPET_WORKS_IN_KVM
 io_apic++;
-
-int_override = (void *)io_apic;
-int_override-type = APIC_XRUPT_OVERRIDE;
-int_override-length = sizeof(*int_override);
-int_override-bus = cpu_to_le32(0);
-int_override-source = cpu_to_le32(0);
-int_override-gsi = cpu_to_le32(2);
-int_override-flags = cpu_to_le32(0);
-#endif
+int_override = (struct madt_int_override*)(io_apic);
+#ifdef BX_QEMU
+if (irq0_override) {
+memset(int_override, 0, sizeof(*int_override));
+int_override-type = APIC_XRUPT_OVERRIDE;
+int_override-length = sizeof(*int_override);
+int_override-source = 0;
+int_override-gsi = 2;
+int_override-flags = 0; /* conforms to bus specifications */
+int_override++;
+}
 #endif
-
-int_override = (struct madt_int_override*)(io_apic + 1);
-for ( i = 0; i  16; i++ ) {
-if ( PCI_ISA_IRQ_MASK  (1U  i) ) {
+for (i = 0; i  16; i++) {
+if (PCI_ISA_IRQ_MASK  (1U  i)) {
 memset(int_override, 0, sizeof(*int_override));
 int_override-type   = APIC_XRUPT_OVERRIDE;
 int_override-length = sizeof(*int_override);
@@ -2708,6 +2739,9 @@ void rombios32_init(uint32_t *s3_resume_vector, uint8_t 
*shutdown_flag)
 
 if (bios_table_cur_addr != 0) {
 
+#ifdef BX_QEMU
+irq0_override_probe();
+#endif
 mptable_init();
 
 smbios_init();
--
To unsubscribe from this list: send the line unsubscribe kvm-commits in
the body of a message to 

[COMMIT master] HPET support with kvm

2009-07-12 Thread Avi Kivity
From: Beth Kon e...@us.ibm.com

The big change here is handling of enabling/disabling of hpet legacy
mode. When hpet enters legacy mode, the spec says that the pit stops
generating interrupts. In practice, we want to stop the pit periodic
timer from running because it is wasteful in a virtual environment.

We also have to worry about the hpet leaving legacy mode (which, at
least in linux, happens only during a shutdown or crash). At this
point, according to the hpet spec, PIT interrupts need to be
reenabled. For us, it means the PIT timer needs to be restarted.

This patch handles this situation better than the earlier versions by
coming closer to just disabling PIT interrupts. It allows the PIT
state to change if the OS modifies it, even while PIT is disabled, but
does not allow a pit timer to start. Then if HPET legacy mode is
disabled, whatever the PIT state is at that point, the PIT timer is
restarted accordingly.

[avi: adjust to kernel header changes]

Signed-off-by: Beth Kon e...@us.ibm.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/hw/hpet.c b/hw/hpet.c
index 186d671..c1837ac 100644
--- a/hw/hpet.c
+++ b/hw/hpet.c
@@ -206,6 +206,9 @@ static int hpet_load(QEMUFile *f, void *opaque, int 
version_id)
 qemu_get_timer(f, s-timer[i].qemu_timer);
 }
 }
+if (hpet_in_legacy_mode()) {
+hpet_disable_pit();
+}
 return 0;
 }
 
@@ -475,9 +478,11 @@ static void hpet_ram_writel(void *opaque, 
target_phys_addr_t addr,
 }
 /* i8254 and RTC are disabled when HPET is in legacy mode */
 if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) {
-hpet_pit_disable();
+hpet_disable_pit();
+dprintf(qemu: hpet disabled pit\n);
 } else if (deactivating_bit(old_val, new_val, 
HPET_CFG_LEGACY)) {
-hpet_pit_enable();
+hpet_enable_pit();
+dprintf(qemu: hpet enabled pit\n);
 }
 break;
 case HPET_CFG + 4:
@@ -554,13 +559,16 @@ static void hpet_reset(void *opaque) {
 /* 64-bit main counter; 3 timers supported; LegacyReplacementRoute. */
 s-capability = 0x8086a201ULL;
 s-capability |= ((HPET_CLK_PERIOD)  32);
-if (count  0)
+s-config = 0ULL;
+if (count  0) {
 /* we don't enable pit when hpet_reset is first called (by hpet_init)
  * because hpet is taking over for pit here. On subsequent invocations,
  * hpet_reset is called due to system reset. At this point control must
  * be returned to pit until SW reenables hpet.
  */
-hpet_pit_enable();
+hpet_enable_pit();
+dprintf(qemu: hpet enabled pit\n);
+}
 count = 1;
 }
 
diff --git a/hw/i8254-kvm.c b/hw/i8254-kvm.c
index 127b347..c54052c 100644
--- a/hw/i8254-kvm.c
+++ b/hw/i8254-kvm.c
@@ -33,15 +33,20 @@ static PITState pit_state;
 static void kvm_pit_save(QEMUFile *f, void *opaque)
 {
 PITState *s = opaque;
-struct kvm_pit_state pit;
+struct kvm_pit_state2 pit2;
 struct kvm_pit_channel_state *c;
 struct PITChannelState *sc;
 int i;
 
-kvm_get_pit(kvm_context, pit);
-
+if(qemu_kvm_has_pit_state2()) {
+kvm_get_pit2(kvm_context, pit2);
+s-flags = pit2.flags;
+} else {
+/* pit2 is superset of pit struct so just cast it and use it */
+kvm_get_pit(kvm_context, (struct kvm_pit_state *)pit2);
+}
 for (i = 0; i  3; i++) {
-   c = pit.channels[i];
+   c = pit2.channels[i];
sc = s-channels[i];
sc-count = c-count;
sc-latched_count = c-latched_count;
@@ -64,15 +69,16 @@ static void kvm_pit_save(QEMUFile *f, void *opaque)
 static int kvm_pit_load(QEMUFile *f, void *opaque, int version_id)
 {
 PITState *s = opaque;
-struct kvm_pit_state pit;
+struct kvm_pit_state2 pit2;
 struct kvm_pit_channel_state *c;
 struct PITChannelState *sc;
 int i;
 
 pit_load(f, s, version_id);
 
+pit2.flags = s-flags;
 for (i = 0; i  3; i++) {
-   c = pit.channels[i];
+   c = pit2.channels[i];
sc = s-channels[i];
c-count = sc-count;
c-latched_count = sc-latched_count;
@@ -89,8 +95,11 @@ static int kvm_pit_load(QEMUFile *f, void *opaque, int 
version_id)
c-count_load_time = sc-count_load_time;
 }
 
-kvm_set_pit(kvm_context, pit);
-
+if(qemu_kvm_has_pit_state2()) {
+kvm_set_pit2(kvm_context, pit2);
+} else {
+kvm_set_pit(kvm_context, (struct kvm_pit_state *)pit2);
+}
 return 0;
 }
 
diff --git a/hw/i8254.c b/hw/i8254.c
index 41d1605..fd0bdfe 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -25,6 +25,7 @@
 #include pc.h
 #include isa.h
 #include qemu-timer.h
+#include qemu-kvm.h
 #include i8254.h
 
 //#define DEBUG_PIT
@@ -196,13 +197,18 @@ int pit_get_mode(PITState *pit, int channel)
 return s-mode;
 }
 
-static inline void 

[COMMIT master] Remove leftover kvm_callbacks structure definition

2009-07-12 Thread Avi Kivity
From: Glauber Costa glom...@redhat.com

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

diff --git a/libkvm-all.h b/libkvm-all.h
index a4193ad..f36d3c3 100644
--- a/libkvm-all.h
+++ b/libkvm-all.h
@@ -105,7 +105,6 @@ int handle_io_window(kvm_context_t kvm);
 int handle_debug(kvm_vcpu_context_t vcpu, void *env);
 int try_push_interrupts(kvm_context_t kvm);
 
-
 #if defined(__x86_64__) || defined(__i386__)
 struct kvm_msr_list *kvm_get_msr_list(kvm_context_t);
 int kvm_get_msrs(kvm_vcpu_context_t, struct kvm_msr_entry *msrs, int n);
@@ -113,62 +112,6 @@ int kvm_set_msrs(kvm_vcpu_context_t, struct kvm_msr_entry 
*msrs, int n);
 #endif
 
 /*!
- * \brief KVM callbacks structure
- *
- * This structure holds pointers to various functions that KVM will call
- * when it encounters something that cannot be virtualized, such as
- * accessing hardware devices via MMIO or regular IO.
- */
-struct kvm_callbacks {
-   /// For 8bit IO reads from the guest (Usually when executing 'inb')
-int (*inb)(void *opaque, uint16_t addr, uint8_t *data);
-   /// For 16bit IO reads from the guest (Usually when executing 'inw')
-int (*inw)(void *opaque, uint16_t addr, uint16_t *data);
-   /// For 32bit IO reads from the guest (Usually when executing 'inl')
-int (*inl)(void *opaque, uint16_t addr, uint32_t *data);
-   /// For 8bit IO writes from the guest (Usually when executing 'outb')
-int (*outb)(void *opaque, uint16_t addr, uint8_t data);
-   /// For 16bit IO writes from the guest (Usually when executing 'outw')
-int (*outw)(void *opaque, uint16_t addr, uint16_t data);
-   /// For 32bit IO writes from the guest (Usually when executing 'outl')
-int (*outl)(void *opaque, uint16_t addr, uint32_t data);
-   /// generic memory reads to unmapped memory (For MMIO devices)
-int (*mmio_read)(void *opaque, uint64_t addr, uint8_t *data,
-   int len);
-   /// generic memory writes to unmapped memory (For MMIO devices)
-int (*mmio_write)(void *opaque, uint64_t addr, uint8_t *data,
-   int len);
-#ifdef KVM_CAP_SET_GUEST_DEBUG
-int (*debug)(void *opaque, void *env,
-struct kvm_debug_exit_arch *arch_info);
-#endif
-   /*!
-* \brief Called when the VCPU issues an 'hlt' instruction.
-*
-* Typically, you should yeild here to prevent 100% CPU utilization
-* on the host CPU.
-*/
-int (*halt)(void *opaque, kvm_vcpu_context_t vcpu);
-int (*shutdown)(void *opaque, void *env);
-int (*io_window)(void *opaque);
-int (*try_push_interrupts)(void *opaque);
-#ifdef KVM_CAP_USER_NMI
-void (*push_nmi)(void *opaque);
-#endif
-void (*post_kvm_run)(void *opaque, void *env);
-int (*pre_kvm_run)(void *opaque, void *env);
-int (*tpr_access)(void *opaque, kvm_vcpu_context_t vcpu, uint64_t rip, int 
is_write);
-#if defined(__s390__)
-int (*s390_handle_intercept)(kvm_context_t context, kvm_vcpu_context_t 
vcpu,
-   struct kvm_run *run);
-int (*s390_handle_reset)(kvm_context_t context, kvm_vcpu_context_t vcpu,
-struct kvm_run *run);
-#endif
-int (*unhandled)(kvm_context_t context, kvm_vcpu_context_t vcpu,
- uint64_t hw_reason);
-};
-
-/*!
  * \brief Create new KVM context
  *
  * This creates a new kvm_context. A KVM context is a small area of data that
--
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 source link

2009-07-12 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

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

diff --git a/linux-2.6 b/linux-2.6
index be5ef0d..ce0c990 16
--- a/linux-2.6
+++ b/linux-2.6
@@ -1 +1 @@
-Subproject commit be5ef0d26ae68aa6825630cdfc2d0f93a36e3ac1
+Subproject commit ce0c990165e183d07cde7c8ed726c37c4f94ae5c
--
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: Always report x2apic as supported feature

2009-07-12 Thread Avi Kivity
From: Gleb Natapov g...@redhat.com

We emulate x2apic in software, so host support is not required.

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

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index e3d9040..dfb0e37 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1504,6 +1504,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, 
u32 function,
case 1:
entry-edx = kvm_supported_word0_x86_features;
entry-ecx = kvm_supported_word4_x86_features;
+   /* we support x2apic emulation even if host does not support
+* it since we emulate x2apic in software */
+   entry-ecx |= F(X2APIC);
break;
/* function 2 entries are STATEFUL. That is, repeated cpuid commands
 * may return different values. This forces us to get_cpu() before
--
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: add module parameters documentation

2009-07-12 Thread Avi Kivity
From: Andre Przywara andre.przyw...@amd.com

Signed-off-by: Andre Przywara andre.przyw...@amd.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index d77fbd8..8ca488d 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -57,6 +57,7 @@ parameter is applicable:
ISAPNP  ISA PnP code is enabled.
ISDNAppropriate ISDN support is enabled.
JOY Appropriate joystick support is enabled.
+   KVM Kernel Virtual Machine support is enabled.
LIBATA  Libata driver is enabled
LP  Printer support is enabled.
LOOPLoopback device support is enabled.
@@ -1098,6 +1099,44 @@ and is between 256 and 4096 characters. It is defined in 
the file
kstack=N[X86] Print N words from the kernel stack
in oops dumps.
 
+   kvm.ignore_msrs=[KVM] Ignore guest accesses to unhandled MSRs.
+   Default is 0 (don't ignore, but inject #GP)
+
+   kvm.oos_shadow= [KVM] Disable out-of-sync shadow paging.
+   Default is 1 (enabled)
+
+   kvm-amd.nested= [KVM,AMD] Allow nested virtualization in KVM/SVM.
+   Default is 0 (off)
+
+   kvm-amd.npt=[KVM,AMD] Disable nested paging (virtualized MMU)
+   for all guests.
+   Default is 1 (enabled) if in 64bit or 32bit-PAE mode
+
+   kvm-intel.bypass_guest_pf=
+   [KVM,Intel] Disables bypassing of guest page faults
+   on Intel chips. Default is 1 (enabled)
+
+   kvm-intel.ept=  [KVM,Intel] Disable extended page tables
+   (virtualized MMU) support on capable Intel chips.
+   Default is 1 (enabled)
+
+   kvm-intel.emulate_invalid_guest_state=
+   [KVM,Intel] Enable emulation of invalid guest states
+   Default is 0 (disabled)
+
+   kvm-intel.flexpriority=
+   [KVM,Intel] Disable FlexPriority feature (TPR shadow).
+   Default is 1 (enabled)
+
+   kvm-intel.unrestricted_guest=
+   [KVM,Intel] Disable unrestricted guest feature
+   (virtualized real and unpaged mode) on capable
+   Intel chips. Default is 1 (enabled)
+
+   kvm-intel.vpid= [KVM,Intel] Disable Virtual Processor Identification
+   feature (tagged TLBs) on capable Intel chips.
+   Default is 1 (enabled)
+
l2cr=   [PPC]
 
l3cr=   [PPC]
--
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: PIT support for HPET legacy mode

2009-07-12 Thread Avi Kivity
From: Beth Kon e...@us.ibm.com

When kvm is in hpet_legacy_mode, the hpet is providing the timer
interrupt and the pit should not be. So in legacy mode, the pit timer
is destroyed, but the *state* of the pit is maintained. So if kvm or
the guest tries to modify the state of the pit, this modification is
accepted, *except* that the timer isn't actually started. When we exit
hpet_legacy_mode, the current state of the pit (which is up to date
since we've been accepting modifications) is used to restart the pit
timer.

The saved_mode code in kvm_pit_load_count temporarily changes mode to
0xff in order to destroy the timer, but then restores the actual
value, again maintaining current state of the pit for possible later
reenablement.

[avi: add some reserved storage in the ioctl; make SET_PIT2 IOW]

Signed-off-by: Beth Kon e...@us.ibm.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/arch/x86/include/asm/kvm.h b/arch/x86/include/asm/kvm.h
index 708b9c3..4a5fe91 100644
--- a/arch/x86/include/asm/kvm.h
+++ b/arch/x86/include/asm/kvm.h
@@ -18,6 +18,7 @@
 #define __KVM_HAVE_GUEST_DEBUG
 #define __KVM_HAVE_MSIX
 #define __KVM_HAVE_MCE
+#define __KVM_HAVE_PIT_STATE2
 
 /* Architectural interrupt line count. */
 #define KVM_NR_INTERRUPTS 256
@@ -237,6 +238,14 @@ struct kvm_pit_state {
struct kvm_pit_channel_state channels[3];
 };
 
+#define KVM_PIT_FLAGS_HPET_LEGACY  0x0001
+
+struct kvm_pit_state2 {
+   struct kvm_pit_channel_state channels[3];
+   __u32 flags;
+   __u32 reserved[9];
+};
+
 struct kvm_reinject_control {
__u8 pit_reinject;
__u8 reserved[31];
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 8c3ac30..9b62c57 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -332,20 +332,33 @@ static void pit_load_count(struct kvm *kvm, int channel, 
u32 val)
case 1:
 /* FIXME: enhance mode 4 precision */
case 4:
-   create_pit_timer(ps, val, 0);
+   if (!(ps-flags  KVM_PIT_FLAGS_HPET_LEGACY)) {
+   create_pit_timer(ps, val, 0);
+   }
break;
case 2:
case 3:
-   create_pit_timer(ps, val, 1);
+   if (!(ps-flags  KVM_PIT_FLAGS_HPET_LEGACY)){
+   create_pit_timer(ps, val, 1);
+   }
break;
default:
destroy_pit_timer(ps-pit_timer);
}
 }
 
-void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val)
+void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val, int 
hpet_legacy_start)
 {
-   pit_load_count(kvm, channel, val);
+   u8 saved_mode;
+   if (hpet_legacy_start) {
+   /* save existing mode for later reenablement */
+   saved_mode = kvm-arch.vpit-pit_state.channels[0].mode;
+   kvm-arch.vpit-pit_state.channels[0].mode = 0xff; /* disable 
timer */
+   pit_load_count(kvm, channel, val);
+   kvm-arch.vpit-pit_state.channels[0].mode = saved_mode;
+   } else {
+   pit_load_count(kvm, channel, val);
+   }
 }
 
 static inline struct kvm_pit *dev_to_pit(struct kvm_io_device *dev)
@@ -554,6 +567,7 @@ void kvm_pit_reset(struct kvm_pit *pit)
struct kvm_kpit_channel_state *c;
 
mutex_lock(pit-pit_state.lock);
+   pit-pit_state.flags = 0;
for (i = 0; i  3; i++) {
c = pit-pit_state.channels[i];
c-mode = 0xff;
diff --git a/arch/x86/kvm/i8254.h b/arch/x86/kvm/i8254.h
index b267018..d4c1c7f 100644
--- a/arch/x86/kvm/i8254.h
+++ b/arch/x86/kvm/i8254.h
@@ -21,6 +21,7 @@ struct kvm_kpit_channel_state {
 
 struct kvm_kpit_state {
struct kvm_kpit_channel_state channels[3];
+   u32 flags;
struct kvm_timer pit_timer;
bool is_periodic;
u32speaker_data_on;
@@ -49,7 +50,7 @@ struct kvm_pit {
 #define KVM_PIT_CHANNEL_MASK   0x3
 
 void kvm_inject_pit_timer_irqs(struct kvm_vcpu *vcpu);
-void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val);
+void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val, int 
hpet_legacy_start);
 struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags);
 void kvm_free_pit(struct kvm *kvm);
 void kvm_pit_reset(struct kvm_pit *pit);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index dfb0e37..1fd67dd 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1213,6 +1213,7 @@ int kvm_dev_ioctl_check_extension(long ext)
case KVM_CAP_ASSIGN_DEV_IRQ:
case KVM_CAP_IRQFD:
case KVM_CAP_PIT2:
+   case KVM_CAP_PIT_STATE2:
r = 1;
break;
case KVM_CAP_COALESCED_MMIO:
@@ -2078,7 +2079,32 @@ static int kvm_vm_ioctl_set_pit(struct kvm *kvm, struct 
kvm_pit_state *ps)
 
mutex_lock(kvm-arch.vpit-pit_state.lock);
memcpy(kvm-arch.vpit-pit_state, ps, sizeof(struct kvm_pit_state));
-   kvm_pit_load_count(kvm, 0, ps-channels[0].count);
+   

[COMMIT master] KVM: MMU: Fix MMU_DEBUG compile breakage

2009-07-12 Thread Avi Kivity
From: Joerg Roedel joerg.roe...@amd.com

Signed-off-by: Joerg Roedel joerg.roe...@amd.com
Signed-off-by: Avi Kivity a...@redhat.com

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 231d880..7162651 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1786,8 +1786,8 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 
*sptep,
pgprintk(%s: setting spte %llx\n, __func__, *sptep);
pgprintk(instantiating %s PTE (%s) at %ld (%llx) addr %p\n,
 is_large_pte(*sptep)? 2MB : 4kB,
-is_present_pte(*sptep)?RW:R, gfn,
-*shadow_pte, sptep);
+*sptep  PT_PRESENT_MASK ?RW:R, gfn,
+*sptep, sptep);
if (!was_rmapped  is_large_pte(*sptep))
++vcpu-kvm-stat.lpages;
 
--
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: ia64: Fix locking around kvm_set_irq()

2009-07-12 Thread Avi Kivity
From: Gleb Natapov g...@redhat.com

kvm_set_irq() uses irq_lock now.

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

diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 8054d7b..d7aa6bb 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -985,10 +985,10 @@ long kvm_arch_vm_ioctl(struct file *filp,
goto out;
if (irqchip_in_kernel(kvm)) {
__s32 status;
-   mutex_lock(kvm-lock);
+   mutex_lock(kvm-irq_lock);
status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID,
irq_event.irq, irq_event.level);
-   mutex_unlock(kvm-lock);
+   mutex_unlock(kvm-irq_lock);
if (ioctl == KVM_IRQ_LINE_STATUS) {
irq_event.status = status;
if (copy_to_user(argp, irq_event,
--
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: Move kvm_cpu_get_interrupt() declaration to x86 code

2009-07-12 Thread Avi Kivity
From: Gleb Natapov g...@redhat.com

It is implemented only by x86.

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

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 30b625d..3f4f00a 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -797,5 +797,6 @@ asmlinkage void kvm_handle_fault_on_reboot(void);
 int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
 int kvm_age_hva(struct kvm *kvm, unsigned long hva);
 int cpuid_maxphyaddr(struct kvm_vcpu *vcpu);
+int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
 
 #endif /* _ASM_X86_KVM_HOST_H */
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 0347d59..7b87a82 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -340,7 +340,6 @@ void kvm_arch_destroy_vm(struct kvm *kvm);
 void kvm_free_all_assigned_devices(struct kvm *kvm);
 void kvm_arch_sync_events(struct kvm *kvm);
 
-int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
 int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
 int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
 void kvm_vcpu_kick(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: Reduce runnability interface with arch support code

2009-07-12 Thread Avi Kivity
From: Gleb Natapov g...@redhat.com

Remove kvm_cpu_has_interrupt() and kvm_arch_interrupt_allowed() from
interface between general code and arch code. kvm_arch_vcpu_runnable()
checks for interrupts instead.

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

diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index d7aa6bb..0ad09f0 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -1935,19 +1935,6 @@ int kvm_highest_pending_irq(struct kvm_vcpu *vcpu)
 return find_highest_bits((int *)vpd-irr[0]);
 }
 
-int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
-{
-   if (kvm_highest_pending_irq(vcpu) != -1)
-   return 1;
-   return 0;
-}
-
-int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu)
-{
-   /* do real check here */
-   return 1;
-}
-
 int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
 {
return vcpu-arch.timer_fired;
@@ -1960,7 +1947,8 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
 
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
 {
-   return vcpu-arch.mp_state == KVM_MP_STATE_RUNNABLE;
+   return (vcpu-arch.mp_state == KVM_MP_STATE_RUNNABLE) ||
+   (kvm_highest_pending_irq(vcpu) != -1);
 }
 
 int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 0341391..2a4551f 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -39,20 +39,9 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
return gfn;
 }
 
-int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
-{
-   return !!(v-arch.pending_exceptions);
-}
-
-int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu)
-{
-   /* do real check here */
-   return 1;
-}
-
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
 {
-   return !(v-arch.msr  MSR_WE);
+   return !(v-arch.msr  MSR_WE) || !!(v-arch.pending_exceptions);
 }
 
 
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index f04f530..5f2e144 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -283,7 +283,7 @@ static int __try_deliver_ckc_interrupt(struct kvm_vcpu 
*vcpu)
return 1;
 }
 
-int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
+static int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
 {
struct kvm_s390_local_interrupt *li = vcpu-arch.local_int;
struct kvm_s390_float_interrupt *fi = vcpu-arch.local_int.float_int;
@@ -320,12 +320,6 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
return rc;
 }
 
-int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu)
-{
-   /* do real check here */
-   return 1;
-}
-
 int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
 {
return 0;
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 3f4f00a..08732d7 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -797,6 +797,8 @@ asmlinkage void kvm_handle_fault_on_reboot(void);
 int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
 int kvm_age_hva(struct kvm *kvm, unsigned long hva);
 int cpuid_maxphyaddr(struct kvm_vcpu *vcpu);
+int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu);
+int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu);
 int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
 
 #endif /* _ASM_X86_KVM_HOST_H */
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index d2e1ffb..48567fa 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4886,8 +4886,10 @@ void kvm_arch_flush_shadow(struct kvm *kvm)
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
 {
return vcpu-arch.mp_state == KVM_MP_STATE_RUNNABLE
-  || vcpu-arch.mp_state == KVM_MP_STATE_SIPI_RECEIVED
-  || vcpu-arch.nmi_pending;
+   || vcpu-arch.mp_state == KVM_MP_STATE_SIPI_RECEIVED
+   || vcpu-arch.nmi_pending ||
+   (kvm_arch_interrupt_allowed(vcpu) 
+kvm_cpu_has_interrupt(vcpu));
 }
 
 void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 7b87a82..f244f11 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -331,7 +331,6 @@ int kvm_arch_hardware_setup(void);
 void kvm_arch_hardware_unsetup(void);
 void kvm_arch_check_processor_compat(void *rtn);
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu);
-int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu);
 
 void kvm_free_physmem(struct kvm *kvm);
 
@@ -340,7 +339,6 @@ void kvm_arch_destroy_vm(struct kvm *kvm);
 void kvm_free_all_assigned_devices(struct kvm *kvm);
 void kvm_arch_sync_events(struct kvm *kvm);
 
-int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
 int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
 void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
 
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 14e1f32..7cd1c10 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1666,9 +1666,7 @@ void kvm_vcpu_block(struct kvm_vcpu 

[COMMIT master] Merge branch 'upstream-merge'

2009-07-12 Thread Avi Kivity
From: Avi Kivity a...@redhat.com

* upstream-merge: (73 commits)
  target-mips: remove useless code in gen_st_cond()
  Fix MIPS SC
  Sparc64: convert ebus to qdev
  sparc64: trap handling corrections
  Sparc32: convert eccmemctl to qdev
  sparc64: fix helper_st_asi little endian case typo
  sparc64: really initialize irq
  sparc64: unify mmu tag matching code
  sparc64: mmu bypass mode correction
  Fix PCI IRQ breakage
  Revert Fix the PCI header type of APB
  Fix APB by reverting 16eaedf2668e9b347a59d73346fcc4c764c58348 partially
  Indent ac97 and es1370 according to audio formatting
  qemu/msi: missing braces
  block: Clean up after deleting BHs
  qemu/msi: clean used vectors state on load
  flush pending aio requests
  kvm: Work around borken MSR_GET_INDEX_LIST
  qemu/virtio: mark msi vectors used on load
  qcow2: Fix L1 table memory allocation
  ...

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: KVM for Linux 2.6.16?

2009-07-12 Thread Avi Kivity

On 07/09/2009 08:49 PM, Cristi Magherusan wrote:



Is KVM not supposed to work on 2.6.16?
 

Hi Anna,

I'm afraid that I have some bad news for you. Usually KVM versions are
tailored to kernel versions contemporary with them. Version 87 is
supposed to need 2.6.26 kernels and newer, IIRC. So for your 2.6.16 you
should try some of the incipient KVM versions, and if you are lucky
enough, they might work.
   


That's incorrect.  We try to keep compatibility from 2.6.16 forward.  
Due to the huge test matrix we often have problems, but once we get 
automatic testing going this will improve.



--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--
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 corrected RFC] uio: add generic driver for PCI 2.3 devices

2009-07-12 Thread Avi Kivity

On 07/10/2009 05:22 AM, Chris Wright wrote:

I know it's not strictly needed for PCI pass through, but it would be
useful to register the IO regions via UIO.  The userspace implementation
would then use UIO strictly instead of poking the sysfs pci info
directly.  I think that ends up being cleaner.
 


I don't see what the advantage is?
   


Have a single fd represent the assigned device, so security can be 
concentrated at that point.  Some privileged server can then hand out 
the fd to qemu.


--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--
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: [FIX REQUEST] Need better management for include/linux/*.h

2009-07-12 Thread Avi Kivity

On 07/11/2009 12:18 PM, Jaswinder Singh Rajput wrote:

Hello all,

As include/linux/*.h file count is going to reach 1000.

We need to do some better techniques to reduce the number of files and
add some hierarchy levels like sub directories where possible.

Like atmel is not exporting to user-space we can easily do :

include/linux/atmel-mci.h -  include/linux/atmel/mci.h
include/linux/atmel_pdc.h -  include/linux/atmel/pdc.h
include/linux/atmel-pwm-bl.h  -  include/linux/atmel/pwm-bl.h
include/linux/atmel_pwm.h -  include/linux/atmel/pwm.h
include/linux/atmel_serial.h  -  include/linux/atmel/serial.h
include/linux/atmel-ssc.h -  include/linux/atmel/ssc.h
include/linux/atmel_tc.h  -  include/linux/atmel/tc.h

Also these files are not exporting :

include/linux/kvm_host.h  -  include/linux/kvm/host.h
include/linux/kvm_para.h  -  include/linux/kvm/para.h
include/linux/kvm_types.h -  include/linux/kvm/types.h

   


IMO a much better move is to place non-ABI files (and the #ifdef KERNEL 
parts of ABI files) outside include/linux.



--
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: question about arch/s390/kvm/interrupt.c

2009-07-12 Thread Avi Kivity

(copying some s390 people)

On 07/10/2009 02:47 PM, Julia Lawall wrote:

In a recent version of linux-next, the function kvm_s390_handle_wait
contains the following code:

 add_wait_queue(vcpu-arch.local_int.wq,wait);
 while (list_empty(vcpu-arch.local_int.list)
 list_empty(vcpu-arch.local_int.float_int-list)
 (!vcpu-arch.local_int.timer_due)
 !signal_pending(current)) {
 set_current_state(TASK_INTERRUPTIBLE);
 spin_unlock_bh(vcpu-arch.local_int.lock);
 spin_unlock(vcpu-arch.local_int.float_int-lock);
 vcpu_put(vcpu);
 schedule();
 vcpu_load(vcpu);
 spin_lock(vcpu-arch.local_int.float_int-lock);
 spin_lock_bh(vcpu-arch.local_int.lock);
 }
 __unset_cpu_idle(vcpu);
 __set_current_state(TASK_RUNNING);
 remove_wait_queue(vcpu-wq,wait);

It seems a bit odd that the first argument to add_wait queue is
vcpu-arch.local_int.wq but the first argument to remove_wait_queue is
vcpu-wq.  I don't see any obvious evidence that they are the same thing,
but perhaps I am missing something.  Should either call be changed?

julia
   



--
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] add KVM module parameters documentation

2009-07-12 Thread Avi Kivity

On 07/10/2009 03:20 PM, Andre Przywara wrote:

Signed-off-by: Andre Przywaraandre.przyw...@amd.com
   


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: [Qemu-devel] Planning for the 0.11.0 release

2009-07-12 Thread Avi Kivity

On 07/10/2009 08:06 PM, Anthony Liguori wrote:
BTW, this is one of the challenges of doing pulls.  I did the pull and 
then deleted every qemu-io patch in my queue since I assumed that 
everything that should go in was part of hch's pull request.  In 
general, that's the only sane way to do pulls so if someone requests a 
pull in the future, please make sure that you've gone through and 
pulled any patch from the list first.


Pulls and stale queues are incompatible.  So long as everything is in 
patches, it doesn't matter since duplicate patches won't apply.  However 
a branch can't be based on a queue (since that's liable to change any 
time), and the branch can't commit and patches in the queue (since the 
queue might be committed any time).  If you want to pull, you'll need to 
shorten your queues (that will improve many other people's quality of 
life, btw).



--
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: slow guest performance with build load, looking for ideas

2009-07-12 Thread Avi Kivity

On 07/09/2009 09:01 PM, Erik Jacobson wrote:



Please drop -usbdevice tablet and set the host I/O scheduler to
deadline.  Add cache=none to the -drive options.
 


yes, these changes make a difference.


Before starting qemu-kvm, I did this to change the IO scheduler:
BEFORE:
# for f in /sys/block/sd*/queue/scheduler; do cat $f; done
noop anticipatory deadline [cfq]
noop anticipatory deadline [cfq]

SET:
# for f in /sys/block/sd*/queue/scheduler; do echo deadline  $f; done

CONFIRM:
# for f in /sys/block/sd*/queue/scheduler; do cat $f; done
noop anticipatory [deadline] cfq
noop anticipatory [deadline] cfq


qemu command line.  Note that usbtablet is off and cache=none is used in
drive options:

/usr/bin/qemu-kvm -M pc -m 4096 -smp 8 -name f11-test -uuid 
b7b4b7e4-9c07-22aa-0c95-d5c8a24176c5 -monitor pty -pidfile 
/var/run/libvirt/qemu//f11-test.pid -drive 
file=/var/lib/libvirt/images/f11-test.img,if=virtio,index=0,boot=on,cache=none 
-drive file=/dev/sdb,if=virtio,index=1,cache=none -drive 
file=/var/lib/libvirt/images/test.img,if=virtio,index=2,cache=none -net 
nic,macaddr=54:52:00:46:48:0e,model=virtio -net user -serial pty -parallel none 
-usb -vnc cct201:1 -soundhw es1370 -redir tcp:::22


# rotation enabled this way in the guest, once the guest was started:
for f in /sys/block/vd*/queue/rotational; do echo 1  $f; done

Test runs after make clean...
time (make -j12   make -j12 modules)

real10m25.585s
user26m36.450s
sys 8m14.776s

2nd trial (make clean followed by the same test again.
real9m21.626s
user26m42.144s
sys 8m14.532s

   


That's a scaling of 3.7, still pretty far from the host and even farther 
than my results.


Is the numa factor of this machine larger than usual?

--
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: [KVM PATCH v10 2/2] KVM: add ioeventfd support

2009-07-12 Thread Avi Kivity

On 07/09/2009 06:00 PM, Gregory Haskins wrote:



+   bool wildcard = args-flags  KVM_IOEVENTFD_FLAG_DATAMATCH ?
+   true : false;

 

Doh!  Inverted logic.  wildcard should be false if DATAMATCH is
defined in the flags.

Avi, please reverse true/false here before accepting (assuming a v11
respin isn't needed).  Of course, if you would prefer me to just submit
a new patch, that is fine too.

   


I changed it to !(...).  I find the predicate ? true : false idiom 
confusing.


--
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: [KVM PATCH v10 0/2] ioeventfd (formerly iosignalfd)

2009-07-12 Thread Avi Kivity

On 07/08/2009 12:08 AM, Gregory Haskins wrote:

(Applies to kvm.git/master:3abaf217)

This is v10 of the series.  For more details, please see the header to
patch 2/2.

This series has been tested against the kvm-eventfd unit test, and
appears to be functioning properly.  You can download this test here:

ftp://ftp.novell.com/dev/ghaskins/kvm-eventfd.tar.bz2

(Note: unit test has been updated to accomodate new feature-set)

Please consider for inclusion to kvm.git

   


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] remove leftover:

2009-07-12 Thread Avi Kivity

On 07/08/2009 03:34 PM, Glauber Costa wrote:

get rid of kvm_callbacks structure definition

   


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: [FIX REQUEST] Need better management for include/linux/*.h

2009-07-12 Thread Andi Kleen
Jaswinder Singh Rajput jaswin...@kernel.org writes:

 Hello all,

 As include/linux/*.h file count is going to reach 1000.

 We need to do some better techniques to reduce the number of files and
 add some hierarchy levels like sub directories where possible.

Why? 100 or 1000 really doesn't make much difference; in both
cases you cannot easily browse and have to use tab completion.
And I doubt your reorganization would go below 100.

I would just leave it as it is.

-Andi
-- 
a...@linux.intel.com -- Speaking for myself only.
--
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 0/9] Move closer to upstream

2009-07-12 Thread Avi Kivity

On 07/10/2009 11:17 PM, Glauber Costa wrote:

Hi,

This is another step at getting us closer to qemu upstream. I'm getting rid
of USE_KVM, replacing it with the combination of KVM_UPSTREAM and CONFIG_KVM

The goal is to slowly reduce that isolation. To demonstrate what I aim
for, the last patches of the series shares code for breakpoint handling.
next in my radar are ioctl functions and cpuid trimming.

Have fun

Changes from v1:
* Include qemu-kvm.c and qemu-kvm-x86.c instead of folding it, as by gleb
   suggestion.
* duplicate structures that we need, to avoid messing with upstream, per
   avi suggestion
* drop KVM_UPSTREAM instead of moving code, per Jan suggestion
* kvm_qemu_init() -  kvm_init(smp_cpus), to get closer to upstream, per
   glommer evil twin suggestion
   


Doesn't apply, again due to the code movement patch.  Just use #includes 
again and leave me instructions for the actual folding.


--
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: Tap initialization

2009-07-12 Thread Avi Kivity

On 07/08/2009 08:17 AM, Stephane Bakhos wrote:
 I've been having some problem with recent releases when it comes to 
tap
 initialization. It seems that the script is ran after the tap is 
opened. I
 think this is a bit weird and useless as I want the script to setup 
the

 tap by itself.

 In net.c, the initialization (I assume) happen in
 static int net_tap_init

 setup_script is called after tap_open with the fd from tap_open as a
 parameter.

 However in setup_script, the fd is basically not used.

 Would there be any reason not to remove the fd parameter to 
setup_script,

 and then call setup_script before tap_open ?

 I've tried it with kvm-86 and it seems to work


You can get the same effect by setting up tap before launching qemu, 
and using qemu -net tap,ifname=...,script=no.


I thought that the point of the scripts was to have qemu create/delete 
taps as needed.


No, the scripts just configure the taps.



Most examples on the internet are based on that.

Another improvement would be to run the down script after qemu stops 
using the taps so that they can be deleted.


How do I create a patch and submit it?


See http://www.linux-kvm.org/page/Code and the numerous git tutorials.

--
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 9/9] reuse upstream breakpoint code

2009-07-12 Thread Gleb Natapov
On Fri, Jul 10, 2009 at 04:18:00PM -0400, Glauber Costa wrote:
 Drop KVM_UPSTREAM around functions we intend to reuse.
 This allow us to share code in kvm-all.c, that is equal in qemu-kvm.c
 
Can we push on_vcpu() to upstream? Then we will be able to reuse
kvm_update_guest_debug() from upstream too.

 Signed-off-by: Glauber Costa glom...@redhat.com
 CC: Jan Kiszka jan.kis...@siemens.com
 ---
  kvm-all.c  |5 ++-
  kvm.h  |1 +
  qemu-kvm.c |  140 
 +---
  3 files changed, 6 insertions(+), 140 deletions(-)
 
 diff --git a/kvm-all.c b/kvm-all.c
 index e42b1f6..67908a7 100644
 --- a/kvm-all.c
 +++ b/kvm-all.c
 @@ -873,6 +873,8 @@ void kvm_setup_guest_memory(void *start, size_t size)
  }
  }
  
 +#endif /* KVM_UPSTREAM */
 +
  #ifdef KVM_CAP_SET_GUEST_DEBUG
  struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
   target_ulong pc)
 @@ -891,6 +893,7 @@ int kvm_sw_breakpoints_active(CPUState *env)
  return !TAILQ_EMPTY(env-kvm_state-kvm_sw_breakpoints);
  }
  
 +#ifdef KVM_UPSTREAM
  int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap)
  {
  struct kvm_guest_debug dbg;
 @@ -904,6 +907,7 @@ int kvm_update_guest_debug(CPUState *env, unsigned long 
 reinject_trap)
  
  return kvm_vcpu_ioctl(env, KVM_SET_GUEST_DEBUG, dbg);
  }
 +#endif
  
  int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
target_ulong len, int type)
 @@ -1028,6 +1032,5 @@ void kvm_remove_all_breakpoints(CPUState *current_env)
  {
  }
  #endif /* !KVM_CAP_SET_GUEST_DEBUG */
 -#endif
  
  #include qemu-kvm.c
 diff --git a/kvm.h b/kvm.h
 index e9a43e2..0191752 100644
 --- a/kvm.h
 +++ b/kvm.h
 @@ -16,6 +16,7 @@
  
  #include config.h
  #include sys-queue.h
 +#include qemu-kvm.h
  
  #ifdef KVM_UPSTREAM
  
 diff --git a/qemu-kvm.c b/qemu-kvm.c
 index 490024e..8778e6d 100644
 --- a/qemu-kvm.c
 +++ b/qemu-kvm.c
 @@ -2424,18 +2424,6 @@ int kvm_qemu_init_env(CPUState *cenv)
  
  #ifdef KVM_CAP_SET_GUEST_DEBUG
  
 -struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
 - target_ulong pc)
 -{
 -struct kvm_sw_breakpoint *bp;
 -
 -TAILQ_FOREACH(bp, env-kvm_state-kvm_sw_breakpoints, entry) {
 - if (bp-pc == pc)
 - return bp;
 -}
 -return NULL;
 -}
 -
  struct kvm_set_guest_debug_data {
  struct kvm_guest_debug dbg;
  int err;
 @@ -2464,133 +2452,7 @@ int kvm_update_guest_debug(CPUState *env, unsigned 
 long reinject_trap)
  return data.err;
  }
  
 -int kvm_sw_breakpoints_active(CPUState *env)
 -{
 -return !TAILQ_EMPTY(env-kvm_state-kvm_sw_breakpoints);
 -}
 -
 -int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
 -  target_ulong len, int type)
 -{
 -struct kvm_sw_breakpoint *bp;
 -CPUState *env;
 -int err;
 -
 -if (type == GDB_BREAKPOINT_SW) {
 - bp = kvm_find_sw_breakpoint(current_env, addr);
 - if (bp) {
 - bp-use_count++;
 - return 0;
 - }
 -
 - bp = qemu_malloc(sizeof(struct kvm_sw_breakpoint));
 - if (!bp)
 - return -ENOMEM;
 -
 - bp-pc = addr;
 - bp-use_count = 1;
 - err = kvm_arch_insert_sw_breakpoint(current_env, bp);
 - if (err) {
 - free(bp);
 - return err;
 - }
 -
 -TAILQ_INSERT_HEAD(current_env-kvm_state-kvm_sw_breakpoints,
 -  bp, entry);
 -} else {
 - err = kvm_arch_insert_hw_breakpoint(addr, len, type);
 - if (err)
 - return err;
 -}
 -
 -for (env = first_cpu; env != NULL; env = env-next_cpu) {
 - err = kvm_update_guest_debug(env, 0);
 - if (err)
 - return err;
 -}
 -return 0;
 -}
 -
 -int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr,
 -  target_ulong len, int type)
 -{
 -struct kvm_sw_breakpoint *bp;
 -CPUState *env;
 -int err;
 -
 -if (type == GDB_BREAKPOINT_SW) {
 - bp = kvm_find_sw_breakpoint(current_env, addr);
 - if (!bp)
 - return -ENOENT;
 -
 - if (bp-use_count  1) {
 - bp-use_count--;
 - return 0;
 - }
 -
 - err = kvm_arch_remove_sw_breakpoint(current_env, bp);
 - if (err)
 - return err;
 -
 - TAILQ_REMOVE(current_env-kvm_state-kvm_sw_breakpoints, bp, entry);
 - qemu_free(bp);
 -} else {
 - err = kvm_arch_remove_hw_breakpoint(addr, len, type);
 - if (err)
 - return err;
 -}
 -
 -for (env = first_cpu; env != NULL; env = env-next_cpu) {
 - err = kvm_update_guest_debug(env, 0);
 - if (err)
 - return err;
 -}
 -return 0;
 -}
 -
 -void kvm_remove_all_breakpoints(CPUState *current_env)
 -{
 -struct kvm_sw_breakpoint *bp, *next;
 -CPUState *env;
 -
 -TAILQ_FOREACH_SAFE(bp, current_env-kvm_state-kvm_sw_breakpoints, 
 entry, next) {
 -if 

Re: [PATCH] kvm/mmu: fix MMU_DEBUG compile breakage

2009-07-12 Thread Avi Kivity

On 07/09/2009 05:36 PM, Joerg Roedel wrote:

Signed-off-by: Joerg Roedeljoerg.roe...@amd.com
   


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] Move irq routing data structure to rcu locking

2009-07-12 Thread Avi Kivity

On 07/09/2009 04:13 PM, Gleb Natapov wrote:

Change it from list to array to make RCU handling simpler.

Signed-off-by: Gleb Natapovg...@redhat.com
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index f54a0d3..12d8d2b 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -161,7 +161,8 @@ struct kvm {

struct mutex irq_lock;
  #ifdef CONFIG_HAVE_KVM_IRQCHIP
-   struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */
+   struct kvm_kernel_irq_routing_entry *irq_routing;
+   spinlock_t irq_routing_lock;
struct hlist_head mask_notifier_list;
  #endif
   


Why the new lock?

--
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] Move irq routing data structure to rcu locking

2009-07-12 Thread Gleb Natapov
On Sun, Jul 12, 2009 at 12:50:05PM +0300, Avi Kivity wrote:
 On 07/09/2009 04:13 PM, Gleb Natapov wrote:
 Change it from list to array to make RCU handling simpler.

 Signed-off-by: Gleb Natapovg...@redhat.com
 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
 index f54a0d3..12d8d2b 100644
 --- a/include/linux/kvm_host.h
 +++ b/include/linux/kvm_host.h
 @@ -161,7 +161,8 @@ struct kvm {

  struct mutex irq_lock;
   #ifdef CONFIG_HAVE_KVM_IRQCHIP
 -struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */
 +struct kvm_kernel_irq_routing_entry *irq_routing;
 +spinlock_t irq_routing_lock;
  struct hlist_head mask_notifier_list;
   #endif


 Why the new lock?

Currently routing table is protected by irq_lock mutex, but irq_lock is
overused. It protects too much of unrelated things and it is not clear what
its real purpose in life. I want to rid of it completely.

--
Gleb.
--
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] [PATCH 1/6] add ebizzy in autotest

2009-07-12 Thread sudhir kumar
On Sat, Jul 11, 2009 at 6:05 AM, Martin Blighmbl...@google.com wrote:
 On Fri, Jul 10, 2009 at 4:29 AM, sudhir kumarsmalik...@gmail.com wrote:
 So is there any plan for adding this patch set in the patch queue? I
 would love to incorporate all the comments if any.

 Yup, just was behind on patches.

 I added it now - the mailer you are using seems to chew patches fairly
 thoroughly though ... if it's gmail, it does that ... might want to just
 attach as text ?
Thanks!
Ah! I have been using gmail only in the text mode. I was unable to
subscribe to the list using my imap id(and i use mutt client for that)
though.
Is this problem of gmail known to all? Any workaround ?


 On Wed, Jul 8, 2009 at 1:47 PM, sudhir kumarsmalik...@gmail.com wrote:
 This patch adds the wrapper for ebizzy into autotest. here is the link
 to get a copy of the test tarball.
 http://sourceforge.net/project/platformdownload.php?group_id=202378sel_platform=3809

 Please review the patch and provide your comments.


 Signed-off-by: Sudhir Kumar sku...@linux.vnet.ibm.com

 Index: autotest/client/tests/ebizzy/control
 ===
 --- /dev/null
 +++ autotest/client/tests/ebizzy/control
 @@ -0,0 +1,11 @@
 +NAME = ebizzy
 +AUTHOR = Sudhir Kumar sku...@linux.vnet.ibm.com
 +TIME = MEDIUM, VARIABLE
 +TEST_CATEGORY = FUNCTIONAL
 +TEST_CLASS = SYSTEM STRESS
 +TEST_TYPE = CLIENT
 +DOC = 
 +http://sourceforge.net/project/platformdownload.php?group_id=202378sel_platform=3809
 +
 +
 +job.run_test('ebizzy', args = '-vv')
 Index: autotest/client/tests/ebizzy/ebizzy.py
 ===
 --- /dev/null
 +++ autotest/client/tests/ebizzy/ebizzy.py
 @@ -0,0 +1,32 @@
 +import os
 +from autotest_lib.client.bin import utils, test
 +from autotest_lib.client.common_lib import error
 +
 +class ebizzy(test.test):
 +    version = 3
 +
 +    def initialize(self):
 +        self.job.require_gcc()
 +
 +
 +    # 
 http://sourceforge.net/project/downloading.php?group_id=202378filename=ebizzy-0.3.tar.gz
 +    def setup(self, tarball = 'ebizzy-0.3.tar.gz'):
 +        tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
 +        utils.extract_tarball_to_dir(tarball, self.srcdir)
 +        os.chdir(self.srcdir)
 +
 +        utils.system('[ -x configure ]  ./configure')
 +        utils.system('make')
 +
 +
 +    # Note: default we use always mmap()
 +    def run_once(self, args = '', num_chunks = 1000, chunk_size =
 512000, seconds = 100, num_threads = 100):
 +
 +        #TODO: Write small functions which will choose many of the above
 +        # variables dynamicaly looking at guest's total resources
 +        logfile = os.path.join(self.resultsdir, 'ebizzy.log')
 +        args2 = '-m -n %s -P -R -s %s -S %s -t %s' % (num_chunks,
 chunk_size, seconds, num_threads)
 +        args = args + ' ' + args2
 +
 +        cmd = os.path.join(self.srcdir, 'ebizzy') + ' ' + args
 +        utils.system(cmd)


 --
 Sudhir Kumar




 --
 Sudhir Kumar





-- 
Sudhir Kumar
--
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] Move exception handling to the same place as other events.

2009-07-12 Thread Avi Kivity

On 07/09/2009 03:33 PM, Gleb Natapov wrote:

Signed-off-by: Gleb Natapovg...@redhat.com
   


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] Reduce interface between kvm general and kvm arch.

2009-07-12 Thread Avi Kivity

On 07/09/2009 03:33 PM, Gleb Natapov wrote:


diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 05b6bc7..cf20dc1 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1666,9 +1666,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
for (;;) {
prepare_to_wait(vcpu-wq,wait, TASK_INTERRUPTIBLE);

-   if ((kvm_arch_interrupt_allowed(vcpu)
-   kvm_cpu_has_interrupt(vcpu)) ||
-   kvm_arch_vcpu_runnable(vcpu)) {
+   if (kvm_arch_vcpu_runnable(vcpu)) {
set_bit(KVM_REQ_UNHALT,vcpu-requests);
break;
}
   


s390 has:


int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
{
/* kvm common code refers to this, but never calls it */
BUG();
return 0;
}

So this needs to be updated.  Please coordinate with the s390 folks.

--
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] Reduce interface between kvm general and kvm arch.

2009-07-12 Thread Gleb Natapov
On Sun, Jul 12, 2009 at 02:03:17PM +0300, Avi Kivity wrote:
 On 07/09/2009 03:33 PM, Gleb Natapov wrote:

 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
 index 05b6bc7..cf20dc1 100644
 --- a/virt/kvm/kvm_main.c
 +++ b/virt/kvm/kvm_main.c
 @@ -1666,9 +1666,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
  for (;;) {
  prepare_to_wait(vcpu-wq,wait, TASK_INTERRUPTIBLE);

 -if ((kvm_arch_interrupt_allowed(vcpu)
 -kvm_cpu_has_interrupt(vcpu)) ||
 -kvm_arch_vcpu_runnable(vcpu)) {
 +if (kvm_arch_vcpu_runnable(vcpu)) {
  set_bit(KVM_REQ_UNHALT,vcpu-requests);
  break;
  }


 s390 has:


 int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
 {
 /* kvm common code refers to this, but never calls it */
 BUG();
 return 0;
 }

 So this needs to be updated.  Please coordinate with the s390 folks.

s390 never calls kvm_vcpu_block(). They implement their own blocking.

--
Gleb.
--
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_cpu_get_interrupt() is implemented only by x86.

2009-07-12 Thread Avi Kivity

On 07/09/2009 03:33 PM, Gleb Natapov wrote:

Move it from global .h file to arch/x86
   


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] IRQ was moved to its own lock.

2009-07-12 Thread Avi Kivity

On 07/09/2009 03:33 PM, Gleb Natapov wrote:

Signed-off-by: Gleb Natapovg...@redhat.com
   


Applied, thanks.  Please copy kvm-ia64 on ia64 patches.

--
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] Reduce interface between kvm general and kvm arch.

2009-07-12 Thread Avi Kivity

On 07/12/2009 02:02 PM, Gleb Natapov wrote:


s390 has:


int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
{
 /* kvm common code refers to this, but never calls it */
 BUG();
 return 0;
}

So this needs to be updated.  Please coordinate with the s390 folks.

 

s390 never calls kvm_vcpu_block(). They implement their own blocking.

   


Right; applied.

--
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] Move irq routing data structure to rcu locking

2009-07-12 Thread Avi Kivity

On 07/12/2009 01:07 PM, Gleb Natapov wrote:

On Sun, Jul 12, 2009 at 12:50:05PM +0300, Avi Kivity wrote:
   

On 07/09/2009 04:13 PM, Gleb Natapov wrote:
 

Change it from list to array to make RCU handling simpler.

Signed-off-by: Gleb Natapovg...@redhat.com
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index f54a0d3..12d8d2b 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -161,7 +161,8 @@ struct kvm {

struct mutex irq_lock;
   #ifdef CONFIG_HAVE_KVM_IRQCHIP
-   struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */
+   struct kvm_kernel_irq_routing_entry *irq_routing;
+   spinlock_t irq_routing_lock;
struct hlist_head mask_notifier_list;
   #endif

   

Why the new lock?

 

Currently routing table is protected by irq_lock mutex, but irq_lock is
overused. It protects too much of unrelated things and it is not clear what
its real purpose in life. I want to rid of it completely.
   


Separate discussion/patch.

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


[PATCH 3/4] Move irq ack notifier list to arch independent code.

2009-07-12 Thread Gleb Natapov
Mask irq notifier list is already there.

Signed-off-by: Gleb Natapov g...@redhat.com
---
 arch/ia64/include/asm/kvm_host.h |1 -
 arch/x86/include/asm/kvm_host.h  |1 -
 include/linux/kvm_host.h |1 +
 virt/kvm/irq_comm.c  |4 ++--
 virt/kvm/kvm_main.c  |1 +
 5 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
index d9b6325..a362e67 100644
--- a/arch/ia64/include/asm/kvm_host.h
+++ b/arch/ia64/include/asm/kvm_host.h
@@ -475,7 +475,6 @@ struct kvm_arch {
struct list_head assigned_dev_head;
struct iommu_domain *iommu_domain;
int iommu_flags;
-   struct hlist_head irq_ack_notifier_list;
 
unsigned long irq_sources_bitmap;
unsigned long irq_states[KVM_IOAPIC_NUM_PINS];
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 08732d7..eb723a7 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -401,7 +401,6 @@ struct kvm_arch{
struct kvm_pic *vpic;
struct kvm_ioapic *vioapic;
struct kvm_pit *vpit;
-   struct hlist_head irq_ack_notifier_list;
int vapics_in_nmi_mode;
 
unsigned int tss_addr;
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 6756b3e..f795f25 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -163,6 +163,7 @@ struct kvm {
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
struct kvm_kernel_irq_routing_entry *irq_routing;
struct hlist_head mask_notifier_list;
+   struct hlist_head irq_ack_notifier_list;
 #endif
 
 #ifdef KVM_ARCH_WANT_MMU_NOTIFIER
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index b2fa3f6..5dde1ef 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -181,7 +181,7 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned 
irqchip, unsigned pin)
}
rcu_read_unlock();
 
-   hlist_for_each_entry(kian, n, kvm-arch.irq_ack_notifier_list, link)
+   hlist_for_each_entry(kian, n, kvm-irq_ack_notifier_list, link)
if (kian-gsi == gsi)
kian-irq_acked(kian);
 }
@@ -190,7 +190,7 @@ void kvm_register_irq_ack_notifier(struct kvm *kvm,
   struct kvm_irq_ack_notifier *kian)
 {
mutex_lock(kvm-irq_lock);
-   hlist_add_head(kian-link, kvm-arch.irq_ack_notifier_list);
+   hlist_add_head(kian-link, kvm-irq_ack_notifier_list);
mutex_unlock(kvm-irq_lock);
 }
 
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 24013b4..53d9b70 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -946,6 +946,7 @@ static struct kvm *kvm_create_vm(void)
goto out;
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
INIT_HLIST_HEAD(kvm-mask_notifier_list);
+   INIT_HLIST_HEAD(kvm-irq_ack_notifier_list);
 #endif
 
 #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
-- 
1.6.2.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 1/4] Move irq routing data structure to rcu locking

2009-07-12 Thread Gleb Natapov

Signed-off-by: Gleb Natapov g...@redhat.com
---
 include/linux/kvm_host.h |2 +-
 virt/kvm/irq_comm.c  |   55 +-
 virt/kvm/kvm_main.c  |1 -
 3 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index f54a0d3..6756b3e 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -161,7 +161,7 @@ struct kvm {
 
struct mutex irq_lock;
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
-   struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */
+   struct kvm_kernel_irq_routing_entry *irq_routing;
struct hlist_head mask_notifier_list;
 #endif
 
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 7af18b8..b2fa3f6 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -148,7 +148,8 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int 
irq, int level)
 * IOAPIC.  So set the bit in both. The guest will ignore
 * writes to the unused one.
 */
-   list_for_each_entry(e, kvm-irq_routing, link)
+   rcu_read_lock();
+   for (e = rcu_dereference(kvm-irq_routing); e  e-set; e++) {
if (e-gsi == irq) {
int r = e-set(e, kvm, sig_level);
if (r  0)
@@ -156,6 +157,8 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int 
irq, int level)
 
ret = r + ((ret  0) ? 0 : ret);
}
+   }
+   rcu_read_unlock();
return ret;
 }
 
@@ -168,12 +171,15 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned 
irqchip, unsigned pin)
 
trace_kvm_ack_irq(irqchip, pin);
 
-   list_for_each_entry(e, kvm-irq_routing, link)
+   rcu_read_lock();
+   for (e = rcu_dereference(kvm-irq_routing); e  e-set; e++) {
if (e-irqchip.irqchip == irqchip 
e-irqchip.pin == pin) {
gsi = e-gsi;
break;
}
+   }
+   rcu_read_unlock();
 
hlist_for_each_entry(kian, n, kvm-arch.irq_ack_notifier_list, link)
if (kian-gsi == gsi)
@@ -264,19 +270,11 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, 
bool mask)
kimn-func(kimn, mask);
 }
 
-static void __kvm_free_irq_routing(struct list_head *irq_routing)
-{
-   struct kvm_kernel_irq_routing_entry *e, *n;
-
-   list_for_each_entry_safe(e, n, irq_routing, link)
-   kfree(e);
-}
-
 void kvm_free_irq_routing(struct kvm *kvm)
 {
-   mutex_lock(kvm-irq_lock);
-   __kvm_free_irq_routing(kvm-irq_routing);
-   mutex_unlock(kvm-irq_lock);
+   /* Called only during vm destruction. Nobody can use the pointer
+  at this stage */
+   kfree(kvm-irq_routing);
 }
 
 static int setup_routing_entry(struct kvm_kernel_irq_routing_entry *e,
@@ -326,43 +324,40 @@ int kvm_set_irq_routing(struct kvm *kvm,
unsigned nr,
unsigned flags)
 {
-   struct list_head irq_list = LIST_HEAD_INIT(irq_list);
-   struct list_head tmp = LIST_HEAD_INIT(tmp);
-   struct kvm_kernel_irq_routing_entry *e = NULL;
+   struct kvm_kernel_irq_routing_entry *new, *old;
unsigned i;
int r;
 
+   /* last element is left zeroed and indicates the end of the array */
+   new = kzalloc(sizeof(*new) * (nr + 1), GFP_KERNEL);
+
+   if (!new)
+   return -ENOMEM;
+
for (i = 0; i  nr; ++i) {
r = -EINVAL;
if (ue-gsi = KVM_MAX_IRQ_ROUTES)
goto out;
if (ue-flags)
goto out;
-   r = -ENOMEM;
-   e = kzalloc(sizeof(*e), GFP_KERNEL);
-   if (!e)
-   goto out;
-   r = setup_routing_entry(e, ue);
+   r = setup_routing_entry(new + i, ue);
if (r)
goto out;
++ue;
-   list_add(e-link, irq_list);
-   e = NULL;
}
 
mutex_lock(kvm-irq_lock);
-   list_splice(kvm-irq_routing, tmp);
-   INIT_LIST_HEAD(kvm-irq_routing);
-   list_splice(irq_list, kvm-irq_routing);
-   INIT_LIST_HEAD(irq_list);
-   list_splice(tmp, irq_list);
+   old = kvm-irq_routing;
+   rcu_assign_pointer(kvm-irq_routing, new);
mutex_unlock(kvm-irq_lock);
 
+   synchronize_rcu();
+
r = 0;
+   new = old;
 
 out:
-   kfree(e);
-   __kvm_free_irq_routing(irq_list);
+   kfree(new);
return r;
 }
 
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index cf20dc1..24013b4 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -945,7 +945,6 @@ static struct kvm *kvm_create_vm(void)
if (IS_ERR(kvm))
goto out;
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
-   INIT_LIST_HEAD(kvm-irq_routing);

[PATCH 4/4] Convert irq notifiers lists to RCU locking.

2009-07-12 Thread Gleb Natapov
Use RCU locking for mask/ack notifiers lists.

Signed-off-by: Gleb Natapov g...@redhat.com
---
 virt/kvm/irq_comm.c |   20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 5dde1ef..ba3a115 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -179,18 +179,18 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned 
irqchip, unsigned pin)
break;
}
}
-   rcu_read_unlock();
 
-   hlist_for_each_entry(kian, n, kvm-irq_ack_notifier_list, link)
+   hlist_for_each_entry_rcu(kian, n, kvm-irq_ack_notifier_list, link)
if (kian-gsi == gsi)
kian-irq_acked(kian);
+   rcu_read_unlock();
 }
 
 void kvm_register_irq_ack_notifier(struct kvm *kvm,
   struct kvm_irq_ack_notifier *kian)
 {
mutex_lock(kvm-irq_lock);
-   hlist_add_head(kian-link, kvm-irq_ack_notifier_list);
+   hlist_add_head_rcu(kian-link, kvm-irq_ack_notifier_list);
mutex_unlock(kvm-irq_lock);
 }
 
@@ -198,8 +198,9 @@ void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
struct kvm_irq_ack_notifier *kian)
 {
mutex_lock(kvm-irq_lock);
-   hlist_del_init(kian-link);
+   hlist_del_init_rcu(kian-link);
mutex_unlock(kvm-irq_lock);
+   synchronize_rcu();
 }
 
 int kvm_request_irq_source_id(struct kvm *kvm)
@@ -246,7 +247,7 @@ void kvm_register_irq_mask_notifier(struct kvm *kvm, int 
irq,
 {
mutex_lock(kvm-irq_lock);
kimn-irq = irq;
-   hlist_add_head(kimn-link, kvm-mask_notifier_list);
+   hlist_add_head_rcu(kimn-link, kvm-mask_notifier_list);
mutex_unlock(kvm-irq_lock);
 }
 
@@ -254,8 +255,9 @@ void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int 
irq,
  struct kvm_irq_mask_notifier *kimn)
 {
mutex_lock(kvm-irq_lock);
-   hlist_del(kimn-link);
+   hlist_del_rcu(kimn-link);
mutex_unlock(kvm-irq_lock);
+   synchronize_rcu();
 }
 
 void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, bool mask)
@@ -263,11 +265,11 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, 
bool mask)
struct kvm_irq_mask_notifier *kimn;
struct hlist_node *n;
 
-   WARN_ON(!mutex_is_locked(kvm-irq_lock));
-
-   hlist_for_each_entry(kimn, n, kvm-mask_notifier_list, link)
+   rcu_read_lock();
+   hlist_for_each_entry_rcu(kimn, n, kvm-mask_notifier_list, link)
if (kimn-irq == irq)
kimn-func(kimn, mask);
+   rcu_read_unlock();
 }
 
 void kvm_free_irq_routing(struct kvm *kvm)
-- 
1.6.2.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 2/4] Unregister ack notifier callback on PIT freeing.

2009-07-12 Thread Gleb Natapov

Signed-off-by: Gleb Natapov g...@redhat.com
---
 arch/x86/kvm/i8254.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 8c3ac30..05e00a8 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -642,6 +642,8 @@ void kvm_free_pit(struct kvm *kvm)
if (kvm-arch.vpit) {
kvm_unregister_irq_mask_notifier(kvm, 0,
   kvm-arch.vpit-mask_notifier);
+   kvm_unregister_irq_ack_notifier(kvm,
+   kvm-arch.vpit-pit_state.irq_ack_notifier);
mutex_lock(kvm-arch.vpit-pit_state.lock);
timer = kvm-arch.vpit-pit_state.pit_timer.timer;
hrtimer_cancel(timer);
-- 
1.6.2.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 0/4] moving irq routing and notifiers to RCU locking

2009-07-12 Thread Gleb Natapov
Make PIT to unregister IRQ ack notifier. Move irq ack notifier list in
teh same place where mask notifier list is.

Gleb Natapov (4):
  Move irq routing data structure to rcu locking
  Unregister ack notifier callback on PIT freeing.
  Move irq ack notifier list to arch independent code.
  Convert irq notifiers lists to RCU locking.

 arch/ia64/include/asm/kvm_host.h |1 -
 arch/x86/include/asm/kvm_host.h  |1 -
 arch/x86/kvm/i8254.c |2 +
 include/linux/kvm_host.h |3 +-
 virt/kvm/irq_comm.c  |   73 ++
 virt/kvm/kvm_main.c  |2 +-
 6 files changed, 40 insertions(+), 42 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] enable x2APIC without interrupt remapping under KVM

2009-07-12 Thread Gleb Natapov
KVM would like to provide x2APIC interface to a guest without emulating
interrupt remapping device. The reason KVM prefers guest to use x2APIC
is that x2APIC interface is better virtualizable and provides better
performance than mmio xAPIC interface:

- msr exits are faster than mmio (no page table walk, emulation)
- no need to read back ICR to look at the busy bit
- one 64 bit ICR write instead of two 32 bit writes
- shared code with the Hyper-V paravirt interface

Included patch changes x2APIC enabling logic to enable it even if IR
initialization failed, but kernel runs under KVM and no apic id is
greater than 255 (if there is one spec requires BIOS to move to x2apic
mode before starting an OS).

Signed-off-by: Gleb Natapov g...@redhat.com
Acked-by: Suresh Siddha suresh.b.sid...@intel.com
---

This is based on x86 tree commit 5b9eea3e7 with checkpatch complains
fixed.

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 0a1c283..6e67916 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -49,6 +49,7 @@
 #include asm/mtrr.h
 #include asm/smp.h
 #include asm/mce.h
+#include asm/kvm_para.h
 
 unsigned int num_processors;
 
@@ -1361,52 +1362,74 @@ void enable_x2apic(void)
 }
 #endif /* CONFIG_X86_X2APIC */
 
-void __init enable_IR_x2apic(void)
+int __init enable_IR(void)
 {
 #ifdef CONFIG_INTR_REMAP
int ret;
-   unsigned long flags;
-   struct IO_APIC_route_entry **ioapic_entries = NULL;
 
ret = dmar_table_init();
if (ret) {
pr_debug(dmar_table_init() failed with %d:\n, ret);
-   goto ir_failed;
+   return 0;
}
 
if (!intr_remapping_supported()) {
pr_debug(intr-remapping not supported\n);
-   goto ir_failed;
+   return 0;
}
 
-
if (!x2apic_preenabled  skip_ioapic_setup) {
pr_info(Skipped enabling intr-remap because of skipping 
io-apic setup\n);
-   return;
+   return 0;
}
 
+   if (enable_intr_remapping(x2apic_supported()))
+   return 0;
+
+   pr_info(Enabled Interrupt-remapping\n);
+
+   return 1;
+
+#endif
+   return 0;
+}
+
+void __init enable_IR_x2apic(void)
+{
+   unsigned long flags;
+   struct IO_APIC_route_entry **ioapic_entries = NULL;
+   int ret, x2apic_enabled = 0;
+
ioapic_entries = alloc_ioapic_entries();
if (!ioapic_entries) {
-   pr_info(Allocate ioapic_entries failed: %d\n, ret);
-   goto end;
+   pr_info(Allocate ioapic_entries failed\n);
+   goto out;
}
 
ret = save_IO_APIC_setup(ioapic_entries);
if (ret) {
pr_info(Saving IO-APIC state failed: %d\n, ret);
-   goto end;
+   goto out;
}
 
local_irq_save(flags);
-   mask_IO_APIC_setup(ioapic_entries);
mask_8259A();
+   mask_IO_APIC_setup(ioapic_entries);
 
-   ret = enable_intr_remapping(x2apic_supported());
-   if (ret)
-   goto end_restore;
+   ret = enable_IR();
+   if (!ret) {
+   /* IR is required if x2apic is enabled by BIOS even
+* when running in kvm since this indicates present
+* of APIC ID  255 */
+   if (max_physical_apicid  255 || !kvm_para_available())
+   goto nox2apic;
+   /* without IR all CPUs can be addressed by IOAPIC/MSI
+* only in physical mode */
+   x2apic_phys = 1;
+   }
 
-   pr_info(Enabled Interrupt-remapping\n);
+   x2apic_enabled = 1;
 
if (x2apic_supported()  !x2apic_mode) {
x2apic_mode = 1;
@@ -1414,41 +1437,30 @@ void __init enable_IR_x2apic(void)
pr_info(Enabled x2apic\n);
}
 
-end_restore:
-   if (ret)
-   /*
-* IR enabling failed
-*/
+nox2apic:
+   if (!ret) /* IR enabling failed */
restore_IO_APIC_setup(ioapic_entries);
-
unmask_8259A();
local_irq_restore(flags);
 
-end:
+out:
if (ioapic_entries)
free_ioapic_entries(ioapic_entries);
 
-   if (!ret)
+   if (x2apic_enabled)
return;
 
-ir_failed:
-   if (x2apic_preenabled)
+   if (x2apic_preenabled) {
+#ifdef CONFIG_INTR_REMAP
panic(x2apic enabled by bios. But IR enabling failed);
-   else if (cpu_has_x2apic)
-   pr_info(Not enabling x2apic,Intr-remapping\n);
 #else
-   if (!cpu_has_x2apic)
-   return;
-
-   if (x2apic_preenabled)
panic(x2apic enabled prior OS handover,
-  enable CONFIG_X86_X2APIC, CONFIG_INTR_REMAP);
+enable CONFIG_X86_X2APIC, CONFIG_INTR_REMAP);
 #endif
-
-   return;
+   } else if (cpu_has_x2apic)
+

[PATCH] always report x2apic as supported feature

2009-07-12 Thread Gleb Natapov
We emulate x2apic in software, so host support is not required.

Signed-off-by: Gleb Natapov g...@redhat.com
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 00844eb..c256da7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1497,6 +1497,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, 
u32 function,
case 1:
entry-edx = kvm_supported_word0_x86_features;
entry-ecx = kvm_supported_word4_x86_features;
+   /* we support x2apic emulation even if host does not support
+  it since we emulate x2apic in software */
+   entry-ecx |= F(X2APIC);
break;
/* function 2 entries are STATEFUL. That is, repeated cpuid commands
 * may return different values. This forces us to get_cpu() before
--
Gleb.
--
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] always report x2apic as supported feature

2009-07-12 Thread Avi Kivity

On 07/12/2009 04:10 PM, Gleb Natapov wrote:

We emulate x2apic in software, so host support is not required.

   


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


[ANNOUNCE] kvm-88 release

2009-07-12 Thread Avi Kivity
kvm-87 wasn't so hot due to networking not working with rtl8139 and 
e1000.  So kvm-88 fixes that and brings a bunch of new features 
(resizable sdl windows, multiboot, x2apic, and more).  Enjoy.


Changes from kvm-87:
- merge upstream qemu.git
  - virtio indirect ring entries
- improves block performance for newer Linux guests
  - -net tap,sndbuf=... option for improving udp performance
  - msi-x support
  - sdl window resize
  - more flexible -net user configuration
  - -cpu host to pass through all host cpu features
  - multiboot support for -kernel
- fix KVM_GET_SUPPORTED_CPUID feature usage (Andre Przywara)
- fix register contents after SIPI (Gleb Natapov)
- re-enable device assignment (Markus Armbruster)
- fix ia64 build (Markus Armbruster)
- fix migration for virtio-net version  7 (Michael S. Tsirkin)
- merge more code with upstream (Glauber Costa)
- fix vnet_hdr checks (Mark McLoughlin)
  - fixes broken tap networking with rtl8139 and e1000
- move extboot to standard optionrom location (Jan Kiszka)
- emulate 32-bit syscall/sysenter instructions on 64-bit guests
  (Andre Przywara)
  - allows cross-vendor live migration with 32-bit userspace on 64-bit 
kernel

- fix s390 memslot initialization for userspace_addr != 0
  (Christian Borntraeger)
- allow s390 stfle instruction to be executed by guest (Christian 
Borntraeger)

- prepare memory slot data structures for multiple large page sizes
  (Joerg Roedel)
- correct missing locking in PIT/IRQCHIP/SET_BSP_CPU ioctl paths
  (Marcelo Tosatti)
- do not allow invalid mtrr/pat settings (Marcelo Tosatti)
- ignore some more AMD system configuration msrs (Andre Przywara)
- introduce module parameter for ignoring unknown msrs (Andre Przywara)
- fix ftrace build when kvm is built into the kernel
- convert powerpc marker probes to tracepoints (Marcelo Tosatti)
- drop old kvmtrace code (Marcelo Tosatti)
- document kvm_io_device locking (Michael S. Tsirkin)
- switch coalesced mmio, PIT creation, io bus to slots_lock
  (Michael S. Tsirkin)
- fix locking imbalance (Jiri Slaby)
- irq tracing
- mmio tracing
- irqfd deassign (Gregory Haskins)
- x2apic support (Gleb Natapov)
- avoid redelivery of edge triggered interrupt before next edge (Gleb 
Natapov)

  - fixes keyboard issues running Windows XP x64 smp installer
- avoid pit division by zero (Marcelo Tosatti)
- fix KVM_GET_MSR_INDEX_LIST user memory corruption (Jan Kiszka)
- drop old cr3 checks in favor of new checks (Jan Kiszka)
- mmu tracing
- basic API documentation
- ignore msi requests if level = 0 (Michael S. Tsirkin)
- ioapic/pic/msi tracing (Gleb Natapov)
- don't kick vcpu if not in guest mode (Gleb Natapov)


Notes:
If you use the modules bundled with kvm-88, you can use any version
of Linux from 2.6.16 upwards.  You may also use kvm-88 userspace with
the kvm modules provided by Linux 2.6.25 or above.  Some features may
only be available in newer releases.


http://www.linux-kvm.org

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--
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] remove unused structs from s390

2009-07-12 Thread Gleb Natapov
They are not used by common code without defines which s390 does not
have.

Signed-off-by: Gleb Natapov g...@redhat.com
diff --git a/arch/s390/include/asm/kvm.h b/arch/s390/include/asm/kvm.h
index 0b2f829..3dfcaeb 100644
--- a/arch/s390/include/asm/kvm.h
+++ b/arch/s390/include/asm/kvm.h
@@ -15,15 +15,6 @@
  */
 #include linux/types.h
 
-/* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
-struct kvm_pic_state {
-   /* no PIC for s390 */
-};
-
-struct kvm_ioapic_state {
-   /* no IOAPIC for s390 */
-};
-
 /* for KVM_GET_REGS and KVM_SET_REGS */
 struct kvm_regs {
/* general purpose regs for s390 */
--
Gleb.
--
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: [ANNOUNCE] kvm-88 release

2009-07-12 Thread Avi Kivity

On 07/12/2009 06:06 PM, John Rousseau wrote:

On 07/12/2009 09:31 AM, Avi Kivity wrote:

kvm-87 wasn't so hot due to networking not working with rtl8139 and
e1000.  So kvm-88 fixes that and brings a bunch of new features
(resizable sdl windows, multiboot, x2apic, and more). Enjoy.


Does anyone have this working with FC11?



I run F11.

I installed FC11 on a new laptop, replacing my old FC9-running laptop 
last week and I have been unable to run my Vista guest since:


# /usr/local/bin/qemu-system-x86_64 -hda /home/jrr/vista-x86_64.img 
-m 1536M -net nic,vlan=0,macaddr=52:54:00:12:32:00 -net 
tap,vlan=0,ifname=tap1 -vga std -full-screen -smp 2 -usb -usbdevice 
tablet


Can you try without -full-screen?  Without -vga std?

Note -usbdevice tablet is only eating your cpu.


gdb reports the following if this is at all helpful:


Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x77cf5910 (LWP 3577)]
0x0035a7c81b3b in memset () from /lib64/libc.so.6
(gdb) where
#0  0x0035a7c81b3b in memset () from /lib64/libc.so.6
#1  0x004324a1 in pthread_attr_setdetachstate ()
#2  0x0052873b in pthread_attr_setdetachstate ()
#3  0x00528873 in pthread_attr_setdetachstate ()
#4  0x00528a16 in pthread_attr_setdetachstate ()
#5  0x0035a880686a in start_thread () from /lib64/libpthread.so.0
#6  0x0035a7cde25d in clone () from /lib64/libc.so.6
#7  0x in ?? ()
(gdb) info threads
  3 Thread 0x7683a910 (LWP 3578)  0x0035a880e778 in pread64 
() from /lib64/libpthread.so.0
* 2 Thread 0x77cf5910 (LWP 3577)  0x0035a7c81b3b in memset () 
from /lib64/libc.so.6
  1 Thread 0x77d4a6f0 (LWP 3564)  0x0035a880d934 in 
__lll_lock_wait () from /lib64/libpthread.so.0




Try ./configure --disable-strip.

--
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: [ANNOUNCE] kvm-88 release

2009-07-12 Thread John Rousseau

On 07/12/2009 09:31 AM, Avi Kivity wrote:

kvm-87 wasn't so hot due to networking not working with rtl8139 and
e1000.  So kvm-88 fixes that and brings a bunch of new features
(resizable sdl windows, multiboot, x2apic, and more). Enjoy.


Does anyone have this working with FC11?

I installed FC11 on a new laptop, replacing my old FC9-running laptop 
last week and I have been unable to run my Vista guest since:



# /usr/local/bin/qemu-system-x86_64 -hda /home/jrr/vista-x86_64.img -m 1536M 
-net nic,vlan=0,macaddr=52:54:00:12:32:00 -net tap,vlan=0,ifname=tap1 -vga std 
-full-screen -smp 2 -usb -usbdevice tablet
Executing /etc/qemu-ifup
Bringing up tap1 for bridged mode...
Adding tap1 to br0...
Bad ram offset 60909fff
Aborted


I've been running this guest since ~kvm-75 on FC9. Dropping the smp, usb 
and full-screen options doesn't help. The crash is after the cylon 
Windows startup bar but before the login screen.


Host is FC11 x86_64, 2.6.29.4-167.fc11.x86_64. Intel P8700. 4GB memory.
Guest is Vista Ultimate 64.

An added bonus is that the crash leaves Xorg in 640x480 resolution. I've 
also seen just a seg fault instead of the Bad ram error.


gdb reports the following if this is at all helpful:


Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x77cf5910 (LWP 3577)]
0x0035a7c81b3b in memset () from /lib64/libc.so.6
(gdb) where
#0  0x0035a7c81b3b in memset () from /lib64/libc.so.6
#1  0x004324a1 in pthread_attr_setdetachstate ()
#2  0x0052873b in pthread_attr_setdetachstate ()
#3  0x00528873 in pthread_attr_setdetachstate ()
#4  0x00528a16 in pthread_attr_setdetachstate ()
#5  0x0035a880686a in start_thread () from /lib64/libpthread.so.0
#6  0x0035a7cde25d in clone () from /lib64/libc.so.6
#7  0x in ?? ()
(gdb) info threads
  3 Thread 0x7683a910 (LWP 3578)  0x0035a880e778 in pread64 () from 
/lib64/libpthread.so.0
* 2 Thread 0x77cf5910 (LWP 3577)  0x0035a7c81b3b in memset () from 
/lib64/libc.so.6
  1 Thread 0x77d4a6f0 (LWP 3564)  0x0035a880d934 in __lll_lock_wait () 
from /lib64/libpthread.so.0


Thanks
-John
--
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: [ANNOUNCE] kvm-88 release (CAN NOT install modules on debian/amd64/2.6.30)

2009-07-12 Thread John Wong

when i make install, i see some warning message like this:
WARNING: __tracepoint_kvm_mmu_paging_element 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_mmu_sync_page 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_mmio [/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] 
undefined!
WARNING: __tracepoint_kvm_mmu_set_accessed_bit 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_exit [/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] 
undefined!
WARNING: __tracepoint_kvm_pio [/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] 
undefined!
WARNING: __tracepoint_kvm_mmu_zap_page 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_pic_set_irq 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_cpuid 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_mmu_unsync_page 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_msr [/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] 
undefined!
WARNING: __tracepoint_kvm_set_irq 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_apic_accept_irq 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_inj_virq 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_hypercall 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_page_fault 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_entry 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_apic [/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] 
undefined!
WARNING: __tracepoint_kvm_ioapic_set_irq 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_apic_ipi 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_cr [/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] 
undefined!
WARNING: __tracepoint_kvm_ack_irq 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_mmu_walker_error 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_mmu_get_page 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_mmu_set_dirty_bit 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_mmu_pagetable_walk 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!
WARNING: __tracepoint_kvm_msi_set_irq 
[/ramdisk/kvm-88/kvm/kernel/x86/kvm.ko] undefined!


when i depmod -a after install, i see some warning message like this:
/sbin/depmod -a
WARNING: Module /lib/modules/2.6.30-1-amd64/extra/kvm-intel.ko ignored, 
due to loop
WARNING: Module /lib/modules/2.6.30-1-amd64/extra/kvm-amd.ko ignored, 
due to loop
WARNING: Loop detected: /lib/modules/2.6.30-1-amd64/extra/kvm.ko which 
needs kvm.ko again!
WARNING: Module /lib/modules/2.6.30-1-amd64/extra/kvm.ko ignored, due to 
loop


when i insmod ./kvm.ko, i see the error message like this:
sudo insmod ./kvm.ko
insmod: error inserting './kvm.ko': -1 Unknown symbol in module
and i can not load the modules on my debian/amd64 kernel-2.6.30

qemu-system-x86_64(kvm-88.tar.gz) is work on  my debian with 
kvm-kmod-2.6.30.1-rc2.tar.gz


Please help, thank you.


--
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: [ANNOUNCE] kvm-88 release (CAN NOT install modules on debian/amd64/2.6.30)

2009-07-12 Thread Avi Kivity

On 07/12/2009 07:01 PM, John Wong wrote:


when i insmod ./kvm.ko, i see the error message like this:
sudo insmod ./kvm.ko
insmod: error inserting './kvm.ko': -1 Unknown symbol in module
and i can not load the modules on my debian/amd64 kernel-2.6.30

qemu-system-x86_64(kvm-88.tar.gz) is work on  my debian with 
kvm-kmod-2.6.30.1-rc2.tar.gz



It may help to compile your 2.6.30 kernel without CONFIG_TRACEPOINTS.

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--
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: [ANNOUNCE] kvm-88 release

2009-07-12 Thread John Rousseau

On 07/12/2009 11:13 AM, Avi Kivity wrote:

On 07/12/2009 06:06 PM, John Rousseau wrote:

# /usr/local/bin/qemu-system-x86_64 -hda /home/jrr/vista-x86_64.img
-m 1536M -net nic,vlan=0,macaddr=52:54:00:12:32:00 -net
tap,vlan=0,ifname=tap1 -vga std -full-screen -smp 2 -usb -usbdevice
tablet


Can you try without -full-screen? Without -vga std?


Losing -vga std allowed the guest to boot.


Note -usbdevice tablet is only eating your cpu.


Cool. Removed.


Try ./configure --disable-strip.



(gdb) set args -hda /home/jrr/vista-x86_64.img -m 1536M -net 
nic,vlan=0,macaddr=52:54:00:12:32:00 -net tap,vlan=0,ifname=tap1 -vga std

...

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x77cf5910 (LWP 2792)]
0x0035a7c81b3b in memset () from /lib64/libc.so.6
(gdb) where
#0  0x0035a7c81b3b in memset () from /lib64/libc.so.6
#1  0x004324a1 in vbe_ioport_write_data (opaque=0x13da5e8, addr=value 
optimized out,
val=value optimized out) at /home/jrr/build/kvm/kvm-88/hw/vga.c:629
#2  0x0052873b in kvm_outw (data=value optimized out, addr=value 
optimized out,
opaque=value optimized out) at /home/jrr/build/kvm/kvm-88/qemu-kvm.c:155
#3  handle_io (data=value optimized out, addr=value optimized out, 
opaque=value optimized out)
at /home/jrr/build/kvm/kvm-88/qemu-kvm.c:877
#4  kvm_run (data=value optimized out, addr=value optimized out, opaque=value 
optimized out)
at /home/jrr/build/kvm/kvm-88/qemu-kvm.c:1103
#5  0x00528873 in kvm_cpu_exec (env=0x0) at 
/home/jrr/build/kvm/kvm-88/qemu-kvm.c:1825
#6  0x00528a16 in kvm_main_loop_cpu (env=value optimized out) at 
/home/jrr/build/kvm/kvm-88/qemu-kvm.c:2007
#7  ap_main_loop (env=value optimized out) at 
/home/jrr/build/kvm/kvm-88/qemu-kvm.c:2044
#8  0x0035a880686a in start_thread () from /lib64/libpthread.so.0
#9  0x0035a7cde25d in clone () from /lib64/libc.so.6
#10 0x in ?? ()


Thanks
-John
--
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: R/W HG memory mappings with kvm?

2009-07-12 Thread Stephen Donnelly
On Sat, Jul 11, 2009 at 5:03 AM, Cam Macdonellc...@cs.ualberta.ca wrote:
 Oops, I realize now that I passed the driver patch both times.  Here is the
 old patch.

 http://patchwork.kernel.org/patch/22363/

 What are you compiling against?  the git tree or a particular version? The
 above patch won't compile against the latest git tree due to changes to how
 BARs are setup in Qemu.  I can send you a patch for the latest tree if you
 need it.

Thanks Cam, I will take a look at this code.

At the moment I have cloned the tree so am intending to work at the
tip. If you have a patch for the latest tree that would be great.

Regards,
Stephen.
--
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] [PATCH 1/6] add ebizzy in autotest

2009-07-12 Thread Lucas Meneghel Rodrigues
On Sun, Jul 12, 2009 at 7:08 AM, sudhir kumarsmalik...@gmail.com wrote:
 On Sat, Jul 11, 2009 at 6:05 AM, Martin Blighmbl...@google.com wrote:
 On Fri, Jul 10, 2009 at 4:29 AM, sudhir kumarsmalik...@gmail.com wrote:
 So is there any plan for adding this patch set in the patch queue? I
 would love to incorporate all the comments if any.

 Yup, just was behind on patches.

 I added it now - the mailer you are using seems to chew patches fairly
 thoroughly though ... if it's gmail, it does that ... might want to just
 attach as text ?
 Thanks!
 Ah! I have been using gmail only in the text mode. I was unable to
 subscribe to the list using my imap id(and i use mutt client for that)
 though.
 Is this problem of gmail known to all? Any workaround ?

Yes, gmail wraps stuff automagically, I don't know any workarounds for
that. The best workaround I'd suggest is git-format-patch and
git-send-email :)
--
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] [AUTOTEST] [PATCH 1/2] Add latest LTP test in autotest

2009-07-12 Thread sudhir kumar
On Tue, Jul 7, 2009 at 12:07 AM, Martin Blighmbl...@google.com wrote:
 Issues: LTP has a history of some of the testcases getting broken.

 Right, that's always the concern with doing this.

 Anyways
 that has nothing to worry about with respect to autotest. One of the known 
 issue
 is broken memory controller issue with latest kernels(cgroups and memory
 resource controller enabled kernels). The workaround for them I use is to
 disable or delete those tests from ltp source and tar it again with the same
 name. Though people might use different workarounds for it.

 OK, Can we encapsulate this into the wrapper though, rather than making
 people do it manually? in the existing ltp.patch or something?


I have rebased the patches and updated the existing ltp.patch. I will
be sending them soon.
Also for runningn ltp under kvm I have generated a patch kvm_ltp.patch
whose purpose is same as of ltp.patch but only for kvm guests. i will
be sending the results of execution on the guest as well as on bare
metal. Thanks everyone for your comments!!


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