All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH 0/3] qemu-kvm fixes (+userspace support for gbpages)
@ 2009-06-17 17:56 Joerg Roedel
  2009-06-17 17:56 ` [PATCH 1/3] qemu-kvm: fix cpuid bitmask in kvm_setup_cpuid() Joerg Roedel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Joerg Roedel @ 2009-06-17 17:56 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

Hi,

this patchset contains two "fixes" to qemu-kvm userspace and the patch to make
gbpages working with qemu-kvm. I am not really sure if this is the right way to
do it or if I missed something. Therefore this patchset is RFC.

Thanks,

	Joerg



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] qemu-kvm: fix cpuid bitmask in kvm_setup_cpuid()
  2009-06-17 17:56 [RFC][PATCH 0/3] qemu-kvm fixes (+userspace support for gbpages) Joerg Roedel
@ 2009-06-17 17:56 ` Joerg Roedel
  2009-06-17 17:56 ` [PATCH 2/3] qemu-kvm: align cpu-features with kvm_supported_cpuid Joerg Roedel
  2009-06-17 17:56 ` [PATCH 3/3] qemu-kvm: add support for gbpages to kvm userspace Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2009-06-17 17:56 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, Joerg Roedel

Fix the bitmask in kvm_setup_cpuid() to a value which represents only the
common bits between cpuid function 0x00000001 and 0x80000001.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 target-i386/libkvm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/target-i386/libkvm.c b/target-i386/libkvm.c
index 0f4e009..6391caf 100644
--- a/target-i386/libkvm.c
+++ b/target-i386/libkvm.c
@@ -644,7 +644,7 @@ uint32_t kvm_get_supported_cpuid(kvm_context_t kvm, uint32_t function, int reg)
 				 */
 				if (function == 0x80000001) {
 					cpuid_1_edx = kvm_get_supported_cpuid(kvm, 1, R_EDX);
-					ret |= cpuid_1_edx & 0xdfeff7ff;
+					ret |= cpuid_1_edx & 0x0183f3ff;
 				}
 				break;
 			}
-- 
1.6.3.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] qemu-kvm: align cpu-features with kvm_supported_cpuid
  2009-06-17 17:56 [RFC][PATCH 0/3] qemu-kvm fixes (+userspace support for gbpages) Joerg Roedel
  2009-06-17 17:56 ` [PATCH 1/3] qemu-kvm: fix cpuid bitmask in kvm_setup_cpuid() Joerg Roedel
@ 2009-06-17 17:56 ` Joerg Roedel
  2009-06-17 17:56 ` [PATCH 3/3] qemu-kvm: add support for gbpages to kvm userspace Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2009-06-17 17:56 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, Joerg Roedel

The cpuid features exposed to the guest are currently not aligned with the bits
returned by the supported_cpuid ioctl. This patch fixes it.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 qemu-kvm-x86.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 729d600..95774c1 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -578,6 +578,13 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
                 if (i == 0xd && copy.regs[R_EAX] == 0)
                     break;
             }
+        } else if (i == 1) {
+            do_cpuid_ent(&cpuid_ent[cpuid_nent], i, 0, &copy);
+            kvm_trim_features(&cpuid_ent[cpuid_nent].edx,
+                              kvm_arch_get_supported_cpuid(cenv, 1, R_EDX));
+            kvm_trim_features(&cpuid_ent[cpuid_nent].ecx,
+                              kvm_arch_get_supported_cpuid(cenv, 1, R_ECX));
+            cpuid_nent++;
         } else
             do_cpuid_ent(&cpuid_ent[cpuid_nent++], i, 0, &copy);
     }
@@ -586,20 +593,19 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
     qemu_kvm_cpuid_on_env(&copy);
     limit = copy.regs[R_EAX];
 
-    for (i = 0x80000000; i <= limit; ++i)
-	do_cpuid_ent(&cpuid_ent[cpuid_nent++], i, 0, &copy);
+    for (i = 0x80000000; i <= limit; ++i) {
+	do_cpuid_ent(&cpuid_ent[cpuid_nent], i, 0, &copy);
+        if (i == 0x80000001) {
+            kvm_trim_features(&cpuid_ent[cpuid_nent].edx,
+                              kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_EDX));
+            kvm_trim_features(&cpuid_ent[cpuid_nent].ecx,
+                              kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_ECX));
+        }
+        ++cpuid_nent;
+    }
 
     kvm_setup_cpuid2(cenv->kvm_cpu_state.vcpu_ctx, cpuid_nent, cpuid_ent);
 
-    kvm_trim_features(&cenv->cpuid_features,
-                      kvm_arch_get_supported_cpuid(cenv, 1, R_EDX));
-    kvm_trim_features(&cenv->cpuid_ext_features,
-                      kvm_arch_get_supported_cpuid(cenv, 1, R_ECX));
-    kvm_trim_features(&cenv->cpuid_ext2_features,
-                      kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_EDX));
-    kvm_trim_features(&cenv->cpuid_ext3_features,
-                      kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_ECX));
-
     return 0;
 }
 
-- 
1.6.3.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] qemu-kvm: add support for gbpages to kvm userspace
  2009-06-17 17:56 [RFC][PATCH 0/3] qemu-kvm fixes (+userspace support for gbpages) Joerg Roedel
  2009-06-17 17:56 ` [PATCH 1/3] qemu-kvm: fix cpuid bitmask in kvm_setup_cpuid() Joerg Roedel
  2009-06-17 17:56 ` [PATCH 2/3] qemu-kvm: align cpu-features with kvm_supported_cpuid Joerg Roedel
@ 2009-06-17 17:56 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2009-06-17 17:56 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, Joerg Roedel

This patch adds a command line parameter to expose the gbpages cpuid bit to the
guest if the kvm kernel module supports it.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 qemu-kvm.c           |    1 +
 qemu-kvm.h           |    1 +
 qemu-options.hx      |    2 ++
 target-i386/helper.c |    3 +++
 vl.c                 |    4 ++++
 5 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/qemu-kvm.c b/qemu-kvm.c
index 2aeb17c..01a889d 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -33,6 +33,7 @@ int kvm_irqchip = 1;
 int kvm_pit = 1;
 int kvm_pit_reinject = 1;
 int kvm_nested = 0;
+int kvm_gbpages = 0;
 kvm_context_t kvm_context;
 
 pthread_mutex_t qemu_mutex = PTHREAD_MUTEX_INITIALIZER;
diff --git a/qemu-kvm.h b/qemu-kvm.h
index fa40542..fc06b96 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -151,6 +151,7 @@ extern int kvm_irqchip;
 extern int kvm_pit;
 extern int kvm_pit_reinject;
 extern int kvm_nested;
+extern int kvm_gbpages;
 extern kvm_context_t kvm_context;
 
 struct ioperm_data {
diff --git a/qemu-options.hx b/qemu-options.hx
index edd99db..fe9e9d3 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1594,6 +1594,8 @@ DEF("pcidevice", HAS_ARG, QEMU_OPTION_pcidevice,
 #endif
 DEF("enable-nesting", 0, QEMU_OPTION_enable_nesting,
     "-enable-nesting enable support for running a VM inside the VM (AMD only)\n")
+DEF("enable-gbpages", 0, QEMU_OPTION_enable_gbpages,
+    "-enable-gbpages enable support for 1GB pages in the guest (if supported)\n")
 DEF("nvram", HAS_ARG, QEMU_OPTION_nvram,
     "-nvram FILE          provide ia64 nvram contents\n")
 DEF("tdf", 0, QEMU_OPTION_tdf,
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 6dc0111..9fb2ae4 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -1607,6 +1607,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
                 *ecx &= ~4UL;
             /* 3dnow */
             *edx &= ~0xc0000000;
+	    /* enable gbpages and let kvm disable it if unsupported */
+	    if (kvm_gbpages)
+		    *edx |= (1UL << 26UL);
         }
         break;
     case 0x80000002:
diff --git a/vl.c b/vl.c
index 845ed54..262ff1b 100644
--- a/vl.c
+++ b/vl.c
@@ -5621,6 +5621,10 @@ int main(int argc, char **argv, char **envp)
 		kvm_nested = 1;
 		break;
 	    }
+	    case QEMU_OPTION_enable_gbpages: {
+		kvm_gbpages = 1;
+		break;
+	    }
 #if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
             case QEMU_OPTION_pcidevice:
 		if (assigned_devices_index >= MAX_DEV_ASSIGN_CMDLINE) {
-- 
1.6.3.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-06-17 17:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-17 17:56 [RFC][PATCH 0/3] qemu-kvm fixes (+userspace support for gbpages) Joerg Roedel
2009-06-17 17:56 ` [PATCH 1/3] qemu-kvm: fix cpuid bitmask in kvm_setup_cpuid() Joerg Roedel
2009-06-17 17:56 ` [PATCH 2/3] qemu-kvm: align cpu-features with kvm_supported_cpuid Joerg Roedel
2009-06-17 17:56 ` [PATCH 3/3] qemu-kvm: add support for gbpages to kvm userspace Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.