Re: [PATCH 1/24] Move nested option from svm.c to x86.c

2010-06-15 Thread Nadav Har'El
On Mon, Jun 14, 2010, Avi Kivity wrote about Re: [PATCH 1/24] Move nested 
option from svm.c to x86.c:
 A global variable names 'nested' is not a good idea.  I recommend having 
 a kvm-intel scope module parameter instead, that also avoids the 0/1/2 
 values.

The rationale behind having a nested flag in x86.c (instead of individually
in svm.c and vmx.c) was that it allows nesting-related logic that is common to
both SVM and VMX to reside in x86.c.

But you are right that this is not very important right now. So in the fixed
patch below I've changed it to be a separate module parameter nested for
each module. As you requested, VMX's nested option defaults to off.


Subject: [PATCH 1/24] Add nested module option to vmx.c

This patch adds a module option nested to vmx.c, which controls whether
the guest can use VMX instructions, i.e., whether we allow nested
virtualization. A similar, but separate, option already exists for the
SVM module.

This option currently defaults to 0, meaning that nested VMX must be
explicitly enabled by giving nested=1. When nested VMX matures, the default
should probably be changed to enable nested VMX by default - just like
nested SVM is currently enabled by default.

Signed-off-by: Nadav Har'El n...@il.ibm.com
---
--- .before/arch/x86/kvm/vmx.c  2010-06-15 17:20:01.0 +0300
+++ .after/arch/x86/kvm/vmx.c   2010-06-15 17:20:01.0 +0300
@@ -67,6 +67,14 @@ module_param(emulate_invalid_guest_state
 static int __read_mostly vmm_exclusive = 1;
 module_param(vmm_exclusive, bool, S_IRUGO);
 
+/*
+ * If nested=1, nested virtualization is supported, i.e., the guest may use
+ * VMX and be a hypervisor for its own guests. If nested=0, the guest may not
+ * use VMX instructions.
+ */
+static int nested = 0;
+module_param(nested, int, S_IRUGO);
+
 #define KVM_GUEST_CR0_MASK_UNRESTRICTED_GUEST  \
(X86_CR0_WP | X86_CR0_NE | X86_CR0_NW | X86_CR0_CD)
 #define KVM_GUEST_CR0_MASK \

-- 
Nadav Har'El|  Tuesday, Jun 15 2010, 3 Tammuz 5770
n...@math.technion.ac.il |-
Phone +972-523-790466, ICQ 13349191 |When everything's coming your way, you're
http://nadav.harel.org.il   |in the wrong lane.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/24] Move nested option from svm.c to x86.c

2010-06-14 Thread Avi Kivity

On 06/13/2010 03:23 PM, Nadav Har'El wrote:

The SVM module had a nested option, on by default, which controls whether
to allow nested virtualization. Now that VMX also supports nested
virtualization, we can move this option to x86.c, for both SVM and VMX.

The nested option takes three possible values. 0 disables nested
virtualization on both SVM and VMX, and 1 enables it on both.
The value 2, which is the default when this module option is not explicitly
set, asks each of SVM or VMX to choose its own default; Currently, VMX
disables nested virtualization in this case, while SVM leaves it enabled.

When nested VMX becomes more mature, this default should probably be changed
to enable nested virtualization on both architectures.

--- .before/arch/x86/kvm/x86.c  2010-06-13 15:01:28.0 +0300
+++ .after/arch/x86/kvm/x86.c   2010-06-13 15:01:28.0 +0300
@@ -95,6 +95,17 @@ EXPORT_SYMBOL_GPL(kvm_x86_ops);
  int ignore_msrs = 0;
  module_param_named(ignore_msrs, ignore_msrs, bool, S_IRUGO | S_IWUSR);

+/* If nested=1, nested virtualization is supported. I.e., the guest may use
+ * VMX or SVM (as appropriate) and be a hypervisor for its own guests.
+ * If nested=0, nested virtualization is not supported.
+ * When nested starts as 2 (which is the default), it is later modified by the
+ * specific module used (VMX or SVM). Currently, nested will be left enabled
+ * on SVM, but reset to 0 on VMX.
+ */
+int nested = 2;
+EXPORT_SYMBOL_GPL(nested);
+module_param(nested, int, S_IRUGO);
+
   



A global variable names 'nested' is not a good idea.  I recommend having 
a kvm-intel scope module parameter instead, that also avoids the 0/1/2 
values.


After the patches are merged we can try to consolidate here.

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