All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm-intel: Auto-load on CPUs with VMX.
@ 2012-03-21  6:33 Josh Triplett
  2012-03-21 13:41 ` Avi Kivity
  2012-03-28 11:26 ` Avi Kivity
  0 siblings, 2 replies; 8+ messages in thread
From: Josh Triplett @ 2012-03-21  6:33 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, kvm, linux-kernel

Enable x86 feature-based autoloading for the kvm-intel module on CPUs
with X86_FEATURE_VMX.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---

I've tested this and it works correctly.  I can also supply the obvious
equivalent patch for kvm-amd on AMD CPUs with SVM, but I don't have any
such CPUs to test that on.

 arch/x86/kvm/vmx.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 3b4c8d8..bb3bcff 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -27,6 +27,7 @@
 #include <linux/highmem.h>
 #include <linux/sched.h>
 #include <linux/moduleparam.h>
+#include <linux/mod_devicetable.h>
 #include <linux/ftrace_event.h>
 #include <linux/slab.h>
 #include <linux/tboot.h>
@@ -51,6 +52,12 @@
 MODULE_AUTHOR("Qumranet");
 MODULE_LICENSE("GPL");
 
+static const struct x86_cpu_id vmx_cpu_id[] = {
+	X86_FEATURE_MATCH(X86_FEATURE_VMX),
+	{}
+};
+MODULE_DEVICE_TABLE(x86cpu, vmx_cpu_id);
+
 static bool __read_mostly enable_vpid = 1;
 module_param_named(vpid, enable_vpid, bool, 0444);
 
-- 
1.7.9.1


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

* Re: [PATCH] kvm-intel: Auto-load on CPUs with VMX.
  2012-03-21  6:33 [PATCH] kvm-intel: Auto-load on CPUs with VMX Josh Triplett
@ 2012-03-21 13:41 ` Avi Kivity
  2012-03-27 12:25   ` Kay Sievers
  2012-03-28 11:26 ` Avi Kivity
  1 sibling, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2012-03-21 13:41 UTC (permalink / raw)
  To: Josh Triplett
  Cc: Marcelo Tosatti, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	x86, kvm, linux-kernel

On 03/21/2012 08:33 AM, Josh Triplett wrote:
> Enable x86 feature-based autoloading for the kvm-intel module on CPUs
> with X86_FEATURE_VMX.
>
> Signed-off-by: Josh Triplett <josh@joshtriplett.org>
> ---
>
> I've tested this and it works correctly.  I can also supply the obvious
> equivalent patch for kvm-amd on AMD CPUs with SVM, but I don't have any
> such CPUs to test that on.
>

On the one hand this makes sense and is consistent with how other
modules are loaded.  On the other hand this will waste memory for
non-virt users running on distro kernels (but distro kernels can
override this new behaviour anyway).

I'm inclined to apply, but will wait for more comments.

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


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

* Re: [PATCH] kvm-intel: Auto-load on CPUs with VMX.
  2012-03-21 13:41 ` Avi Kivity
@ 2012-03-27 12:25   ` Kay Sievers
  0 siblings, 0 replies; 8+ messages in thread
From: Kay Sievers @ 2012-03-27 12:25 UTC (permalink / raw)
  To: Avi Kivity
  Cc: Josh Triplett, Marcelo Tosatti, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, kvm, linux-kernel

On Wed, Mar 21, 2012 at 14:41, Avi Kivity <avi@redhat.com> wrote:
> On 03/21/2012 08:33 AM, Josh Triplett wrote:
>> Enable x86 feature-based autoloading for the kvm-intel module on CPUs
>> with X86_FEATURE_VMX.
>>
>> Signed-off-by: Josh Triplett <josh@joshtriplett.org>
>> ---
>>
>> I've tested this and it works correctly.  I can also supply the obvious
>> equivalent patch for kvm-amd on AMD CPUs with SVM, but I don't have any
>> such CPUs to test that on.
>>
>
> On the one hand this makes sense and is consistent with how other
> modules are loaded.  On the other hand this will waste memory for
> non-virt users running on distro kernels (but distro kernels can
> override this new behaviour anyway).
>
> I'm inclined to apply, but will wait for more comments.

Today, we auto-load matching modules for everything we find. It seems
still the best compromise for the default behaviour to make things
work without special care or knowledge, especially for distribution
users.

People who care, can simply 'optimize' that with blacklisting the
aliases in the modprobe config. That way stuff does not get
auto-loaded, but can still be modprobed manually by the module name.

We used to load these modules with rather broken shell scripts, poking
around in /proc/cpuinfo during bootup, anyway. So this standard way of
using an alias is by far the better alternative to it, and I'm all for
doing that.

For what it's worth:
  Acked-By: Kay Sievers <kay@vrfy.org>

Thanks,
Kay

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

* Re: [PATCH] kvm-intel: Auto-load on CPUs with VMX.
  2012-03-21  6:33 [PATCH] kvm-intel: Auto-load on CPUs with VMX Josh Triplett
  2012-03-21 13:41 ` Avi Kivity
@ 2012-03-28 11:26 ` Avi Kivity
  2012-03-28 18:32   ` [PATCH] kvm-amd: Auto-load on CPUs with SVM Josh Triplett
  1 sibling, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2012-03-28 11:26 UTC (permalink / raw)
  To: Josh Triplett
  Cc: Marcelo Tosatti, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	x86, kvm, linux-kernel, Kay Sievers

On 03/21/2012 08:33 AM, Josh Triplett wrote:
> Enable x86 feature-based autoloading for the kvm-intel module on CPUs
> with X86_FEATURE_VMX.
>

Thanks, applied.

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


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

* [PATCH] kvm-amd: Auto-load on CPUs with SVM.
  2012-03-28 11:26 ` Avi Kivity
@ 2012-03-28 18:32   ` Josh Triplett
  2012-03-29  6:33     ` Michael Tokarev
  2012-04-12  1:15     ` Marcelo Tosatti
  0 siblings, 2 replies; 8+ messages in thread
From: Josh Triplett @ 2012-03-28 18:32 UTC (permalink / raw)
  To: Avi Kivity
  Cc: Marcelo Tosatti, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	x86, kvm, linux-kernel, Kay Sievers

Enable x86 feature-based autoloading for the kvm-amd module on CPUs
with X86_FEATURE_SVM.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---

On Wed, Mar 28, 2012 at 01:26:01PM +0200, Avi Kivity wrote:
> On 03/21/2012 08:33 AM, Josh Triplett wrote:
> > Enable x86 feature-based autoloading for the kvm-intel module on CPUs
> > with X86_FEATURE_VMX.
> 
> Thanks, applied.

As promised, the corresponding patch for kvm-amd.

 arch/x86/kvm/svm.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index e385214..cd95ea7 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -22,6 +22,7 @@
 #include "x86.h"
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/kernel.h>
 #include <linux/vmalloc.h>
 #include <linux/highmem.h>
@@ -42,6 +43,12 @@
 MODULE_AUTHOR("Qumranet");
 MODULE_LICENSE("GPL");
 
+static const struct x86_cpu_id svm_cpu_id[] = {
+	X86_FEATURE_MATCH(X86_FEATURE_SVM),
+	{}
+};
+MODULE_DEVICE_TABLE(x86cpu, svm_cpu_id);
+
 #define IOPM_ALLOC_ORDER 2
 #define MSRPM_ALLOC_ORDER 1
 

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

* Re: [PATCH] kvm-amd: Auto-load on CPUs with SVM.
  2012-03-28 18:32   ` [PATCH] kvm-amd: Auto-load on CPUs with SVM Josh Triplett
@ 2012-03-29  6:33     ` Michael Tokarev
  2012-03-29  7:03       ` Josh Triplett
  2012-04-12  1:15     ` Marcelo Tosatti
  1 sibling, 1 reply; 8+ messages in thread
From: Michael Tokarev @ 2012-03-29  6:33 UTC (permalink / raw)
  To: Josh Triplett
  Cc: Avi Kivity, Marcelo Tosatti, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, kvm, linux-kernel, Kay Sievers

On 28.03.2012 22:32, Josh Triplett wrote:
> Enable x86 feature-based autoloading for the kvm-amd module on CPUs
> with X86_FEATURE_SVM.
> 
> Signed-off-by: Josh Triplett <josh@joshtriplett.org>

It appears to work fine on my amd boxen.  The only problem
is that I've no idea when it will be possible to finally
disable the init script (shipped in Debian and other distros)
to load the module based on /proc/cpuinfo contents.  It will
do nothing on kernels with this (or kvm-intel) change applied,
but we still need to support older kernels without that feature... :)

Josh, and I'm sure you will be the first who'll file a bugreport
against qemu-kvm in Debian requesting the startup script to be
removed!.. ;))

Thanks,

/mjt

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

* Re: [PATCH] kvm-amd: Auto-load on CPUs with SVM.
  2012-03-29  6:33     ` Michael Tokarev
@ 2012-03-29  7:03       ` Josh Triplett
  0 siblings, 0 replies; 8+ messages in thread
From: Josh Triplett @ 2012-03-29  7:03 UTC (permalink / raw)
  To: Michael Tokarev
  Cc: Avi Kivity, Marcelo Tosatti, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, kvm, linux-kernel, Kay Sievers

On Thu, Mar 29, 2012 at 10:33:25AM +0400, Michael Tokarev wrote:
> On 28.03.2012 22:32, Josh Triplett wrote:
> > Enable x86 feature-based autoloading for the kvm-amd module on CPUs
> > with X86_FEATURE_SVM.
> > 
> > Signed-off-by: Josh Triplett <josh@joshtriplett.org>
> 
> It appears to work fine on my amd boxen.

Thanks for testing it.  Can I interpret that as a Tested-by/Acked-by?

> The only problem
> is that I've no idea when it will be possible to finally
> disable the init script (shipped in Debian and other distros)
> to load the module based on /proc/cpuinfo contents.  It will
> do nothing on kernels with this (or kvm-intel) change applied,
> but we still need to support older kernels without that feature... :)

Each stable release of Debian has a specific minimum kernel version that
it supports, typically determined by the requirements of packages such
as udev.  As far as I know, the next stable release will ship with 3.2,
and I don't think the necessary infrastructure exists in 3.2 to backport
this patch (though I'd love to hear otherwise if it does), so that
release will probably need to include the init script.  However, the
next release should have no problem safely dropping it and requiring a
sufficiently new kernel.

In unstable (after the release), qemu-kvm could just go ahead and
drop the script with a NEWS.Debian entry telling people to add the
necessary module to /etc/modules if they have an older kernel.

> Josh, and I'm sure you will be the first who'll file a bugreport
> against qemu-kvm in Debian requesting the startup script to be
> removed!.. ;))

I don't know where you could possibly get that idea. ;)

- Josh Triplett

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

* Re: [PATCH] kvm-amd: Auto-load on CPUs with SVM.
  2012-03-28 18:32   ` [PATCH] kvm-amd: Auto-load on CPUs with SVM Josh Triplett
  2012-03-29  6:33     ` Michael Tokarev
@ 2012-04-12  1:15     ` Marcelo Tosatti
  1 sibling, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2012-04-12  1:15 UTC (permalink / raw)
  To: Josh Triplett
  Cc: Avi Kivity, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	kvm, linux-kernel, Kay Sievers

On Wed, Mar 28, 2012 at 11:32:28AM -0700, Josh Triplett wrote:
> Enable x86 feature-based autoloading for the kvm-amd module on CPUs
> with X86_FEATURE_SVM.
> 
> Signed-off-by: Josh Triplett <josh@joshtriplett.org>
> ---
> 
> On Wed, Mar 28, 2012 at 01:26:01PM +0200, Avi Kivity wrote:
> > On 03/21/2012 08:33 AM, Josh Triplett wrote:
> > > Enable x86 feature-based autoloading for the kvm-intel module on CPUs
> > > with X86_FEATURE_VMX.
> > 
> > Thanks, applied.
> 
> As promised, the corresponding patch for kvm-amd.
> 
>  arch/x86/kvm/svm.c |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)

Applied, thanks.


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

end of thread, other threads:[~2012-04-12  4:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-21  6:33 [PATCH] kvm-intel: Auto-load on CPUs with VMX Josh Triplett
2012-03-21 13:41 ` Avi Kivity
2012-03-27 12:25   ` Kay Sievers
2012-03-28 11:26 ` Avi Kivity
2012-03-28 18:32   ` [PATCH] kvm-amd: Auto-load on CPUs with SVM Josh Triplett
2012-03-29  6:33     ` Michael Tokarev
2012-03-29  7:03       ` Josh Triplett
2012-04-12  1:15     ` Marcelo Tosatti

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.