public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* IA32_FEATURE_CONTROL MSR in nested virt
@ 2013-07-03  8:24 Arthur Chunqi Li
  2013-07-03  8:32 ` Paolo Bonzini
  2013-07-03  9:14 ` Gleb Natapov
  0 siblings, 2 replies; 8+ messages in thread
From: Arthur Chunqi Li @ 2013-07-03  8:24 UTC (permalink / raw)
  To: kvm; +Cc: Gleb Natapov, Paolo Bonzini, Jan Kiszka

Hi Gleb and Paolo,
When I write test cases for nested virt and found that reading/writing
 IA32_FEATURE_CONTROL will be simply ignored or return 0 (in
arch/x86/kvm/vmx.c) in VM. Checking this MSR will be done by some
hypervisors (e.g. NOVA) and may cause error then, so it is necessary
to behave right when read/write it in VM.

Are there any difficulties to handle this MSR? I have two solutions.
The first one is return the value of physical CPU's and always return
true when write. This is simple but may behave as if it is a VM
because write to it after VMXON will not return GP exception. This
solution can solve most basic problems since this MSR is not commonly
used. Another solution is adding a field in VCPU to handle this MSR.
This is a complex but better method.

I think I can complete this if needed.

Thanks,
Arthur

--
Arthur Chunqi Li
Department of Computer Science
School of EECS
Peking University
Beijing, China

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

* Re: IA32_FEATURE_CONTROL MSR in nested virt
  2013-07-03  8:24 IA32_FEATURE_CONTROL MSR in nested virt Arthur Chunqi Li
@ 2013-07-03  8:32 ` Paolo Bonzini
  2013-07-03  8:46   ` Zhang, Yang Z
  2013-07-03  9:14 ` Gleb Natapov
  1 sibling, 1 reply; 8+ messages in thread
From: Paolo Bonzini @ 2013-07-03  8:32 UTC (permalink / raw)
  To: Arthur Chunqi Li; +Cc: kvm, Gleb Natapov, Jan Kiszka

Il 03/07/2013 10:24, Arthur Chunqi Li ha scritto:
> Hi Gleb and Paolo,
> When I write test cases for nested virt and found that reading/writing
>  IA32_FEATURE_CONTROL will be simply ignored or return 0 (in
> arch/x86/kvm/vmx.c) in VM. Checking this MSR will be done by some
> hypervisors (e.g. NOVA) and may cause error then, so it is necessary
> to behave right when read/write it in VM.
> 
> Are there any difficulties to handle this MSR? I have two solutions.
> The first one is return the value of physical CPU's and always return
> true when write. This is simple but may behave as if it is a VM
> because write to it after VMXON will not return GP exception. This
> solution can solve most basic problems since this MSR is not commonly
> used. Another solution is adding a field in VCPU to handle this MSR.
> This is a complex but better method.
> 
> I think I can complete this if needed.

Would it be enough to return 5 (binary 101) on reads if nested VMX is
enabled, and #GP on writes?

Paolo

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

* RE: IA32_FEATURE_CONTROL MSR in nested virt
  2013-07-03  8:32 ` Paolo Bonzini
@ 2013-07-03  8:46   ` Zhang, Yang Z
  2013-07-03  8:58     ` Paolo Bonzini
  0 siblings, 1 reply; 8+ messages in thread
From: Zhang, Yang Z @ 2013-07-03  8:46 UTC (permalink / raw)
  To: Paolo Bonzini, Arthur Chunqi Li; +Cc: kvm, Gleb Natapov, Jan Kiszka


>Il 03/07/2013 10:24, Arthur Chunqi Li ha scritto:
>> Hi Gleb and Paolo,
>> When I write test cases for nested virt and found that reading/writing  
>> IA32_FEATURE_CONTROL will be simply ignored or return 0 (in
>> arch/x86/kvm/vmx.c) in VM. Checking this MSR will be done by some 
>> hypervisors (e.g. NOVA) and may cause error then, so it is necessary 
>> to behave right when read/write it in VM.
>> 
> >Are there any difficulties to handle this MSR? I have two solutions.
> >The first one is return the value of physical CPU's and always return 
> >true when write. This is simple but may behave as if it is a VM 
> >because write to it after VMXON will not return GP exception. This 
> >solution can solve most basic problems since this MSR is not commonly 
> >used. Another solution is adding a field in VCPU to handle this MSR.
> >This is a complex but better method.
> >
> >I think I can complete this if needed.
>
>Would it be enough to return 5 (binary 101) on reads if nested VMX is enabled, and #GP on writes?
Agree!, It should be enough. You cannot return physical value directly since there is no SMX in nested.

Best regards,
Yang

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

* Re: IA32_FEATURE_CONTROL MSR in nested virt
  2013-07-03  8:46   ` Zhang, Yang Z
@ 2013-07-03  8:58     ` Paolo Bonzini
  0 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2013-07-03  8:58 UTC (permalink / raw)
  To: Zhang, Yang Z; +Cc: Arthur Chunqi Li, kvm, Gleb Natapov, Jan Kiszka

Il 03/07/2013 10:46, Zhang, Yang Z ha scritto:
> 
>> Il 03/07/2013 10:24, Arthur Chunqi Li ha scritto:
>>> Hi Gleb and Paolo,
>>> When I write test cases for nested virt and found that reading/writing  
>>> IA32_FEATURE_CONTROL will be simply ignored or return 0 (in
>>> arch/x86/kvm/vmx.c) in VM. Checking this MSR will be done by some 
>>> hypervisors (e.g. NOVA) and may cause error then, so it is necessary 
>>> to behave right when read/write it in VM.
>>>
>>> Are there any difficulties to handle this MSR? I have two solutions.
>>> The first one is return the value of physical CPU's and always return 
>>> true when write. This is simple but may behave as if it is a VM 
>>> because write to it after VMXON will not return GP exception. This 
>>> solution can solve most basic problems since this MSR is not commonly 
>>> used. Another solution is adding a field in VCPU to handle this MSR.
>>> This is a complex but better method.
>>>
>>> I think I can complete this if needed.
>>
>> Would it be enough to return 5 (binary 101) on reads if nested VMX is enabled, and #GP on writes?
> Agree!, It should be enough. You cannot return physical value directly since there is no SMX in nested.

Arthur, are you writing a patch?

Paolo

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

* Re: IA32_FEATURE_CONTROL MSR in nested virt
  2013-07-03  8:24 IA32_FEATURE_CONTROL MSR in nested virt Arthur Chunqi Li
  2013-07-03  8:32 ` Paolo Bonzini
@ 2013-07-03  9:14 ` Gleb Natapov
  2013-07-03  9:32   ` Gmail
  2013-07-03 14:48   ` Bandan Das
  1 sibling, 2 replies; 8+ messages in thread
From: Gleb Natapov @ 2013-07-03  9:14 UTC (permalink / raw)
  To: Arthur Chunqi Li; +Cc: kvm, Paolo Bonzini, Jan Kiszka

On Wed, Jul 03, 2013 at 04:24:33PM +0800, Arthur Chunqi Li wrote:
> Hi Gleb and Paolo,
> When I write test cases for nested virt and found that reading/writing
>  IA32_FEATURE_CONTROL will be simply ignored or return 0 (in
> arch/x86/kvm/vmx.c) in VM. Checking this MSR will be done by some
> hypervisors (e.g. NOVA) and may cause error then, so it is necessary
> to behave right when read/write it in VM.
> 
NOVA cannot write to it and expect anything but #GP since BIOSes usually
lock the MSR. So I agree with Paolo about returning 5 on read and #GP on
write. Later we can implement locking functionality and make BIOS
enable/disable nested vmx.

> Are there any difficulties to handle this MSR? I have two solutions.
> The first one is return the value of physical CPU's and always return
> true when write. This is simple but may behave as if it is a VM
> because write to it after VMXON will not return GP exception. This
> solution can solve most basic problems since this MSR is not commonly
> used. Another solution is adding a field in VCPU to handle this MSR.
> This is a complex but better method.
> 
> I think I can complete this if needed.
> 
> Thanks,
> Arthur
> 
> --
> Arthur Chunqi Li
> Department of Computer Science
> School of EECS
> Peking University
> Beijing, China

--
			Gleb.

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

* Re: IA32_FEATURE_CONTROL MSR in nested virt
  2013-07-03  9:14 ` Gleb Natapov
@ 2013-07-03  9:32   ` Gmail
  2013-07-03 14:48   ` Bandan Das
  1 sibling, 0 replies; 8+ messages in thread
From: Gmail @ 2013-07-03  9:32 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, Paolo Bonzini, Jan Kiszka

OK, I will write a patch as what Paolo says. Anything else need to be taken into consideration, Paolo?

Arthur Chunqi Li
Department of Computer Science
School of EECS
Peking University
Beijing, China

From my iPhone

在 2013-7-3,17:14,Gleb Natapov <gleb@redhat.com> 写道:

> On Wed, Jul 03, 2013 at 04:24:33PM +0800, Arthur Chunqi Li wrote:
>> Hi Gleb and Paolo,
>> When I write test cases for nested virt and found that reading/writing
>> IA32_FEATURE_CONTROL will be simply ignored or return 0 (in
>> arch/x86/kvm/vmx.c) in VM. Checking this MSR will be done by some
>> hypervisors (e.g. NOVA) and may cause error then, so it is necessary
>> to behave right when read/write it in VM.
> NOVA cannot write to it and expect anything but #GP since BIOSes usually
> lock the MSR. So I agree with Paolo about returning 5 on read and #GP on
> write. Later we can implement locking functionality and make BIOS
> enable/disable nested vmx.
> 
>> Are there any difficulties to handle this MSR? I have two solutions.
>> The first one is return the value of physical CPU's and always return
>> true when write. This is simple but may behave as if it is a VM
>> because write to it after VMXON will not return GP exception. This
>> solution can solve most basic problems since this MSR is not commonly
>> used. Another solution is adding a field in VCPU to handle this MSR.
>> This is a complex but better method.
>> 
>> I think I can complete this if needed.
>> 
>> Thanks,
>> Arthur
>> 
>> --
>> Arthur Chunqi Li
>> Department of Computer Science
>> School of EECS
>> Peking University
>> Beijing, China
> 
> --
>            Gleb.

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

* Re: IA32_FEATURE_CONTROL MSR in nested virt
  2013-07-03  9:14 ` Gleb Natapov
  2013-07-03  9:32   ` Gmail
@ 2013-07-03 14:48   ` Bandan Das
  2013-07-03 14:59     ` Gleb Natapov
  1 sibling, 1 reply; 8+ messages in thread
From: Bandan Das @ 2013-07-03 14:48 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: Arthur Chunqi Li, kvm, Paolo Bonzini, Jan Kiszka

Gleb Natapov <gleb@redhat.com> writes:

> On Wed, Jul 03, 2013 at 04:24:33PM +0800, Arthur Chunqi Li wrote:
>> Hi Gleb and Paolo,
>> When I write test cases for nested virt and found that reading/writing
>>  IA32_FEATURE_CONTROL will be simply ignored or return 0 (in
>> arch/x86/kvm/vmx.c) in VM. Checking this MSR will be done by some
>> hypervisors (e.g. NOVA) and may cause error then, so it is necessary
>> to behave right when read/write it in VM.
>> 
> NOVA cannot write to it and expect anything but #GP since BIOSes usually
> lock the MSR. So I agree with Paolo about returning 5 on read and #GP on
> write. Later we can implement locking functionality and make BIOS
> enable/disable nested vmx.

I vaguely recalled Nadav had posted a patch related to this MSR a
while back and found this :

http://permalink.gmane.org/gmane.comp.emulators.kvm.devel/88478

Shouldn't this work ?

>> Are there any difficulties to handle this MSR? I have two solutions.
>> The first one is return the value of physical CPU's and always return
>> true when write. This is simple but may behave as if it is a VM
>> because write to it after VMXON will not return GP exception. This
>> solution can solve most basic problems since this MSR is not commonly
>> used. Another solution is adding a field in VCPU to handle this MSR.
>> This is a complex but better method.
>> 
>> I think I can complete this if needed.
>> 
>> Thanks,
>> Arthur
>> 
>> --
>> Arthur Chunqi Li
>> Department of Computer Science
>> School of EECS
>> Peking University
>> Beijing, China
>
> --
> 			Gleb.
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: IA32_FEATURE_CONTROL MSR in nested virt
  2013-07-03 14:48   ` Bandan Das
@ 2013-07-03 14:59     ` Gleb Natapov
  0 siblings, 0 replies; 8+ messages in thread
From: Gleb Natapov @ 2013-07-03 14:59 UTC (permalink / raw)
  To: Bandan Das; +Cc: Arthur Chunqi Li, kvm, Paolo Bonzini, Jan Kiszka

On Wed, Jul 03, 2013 at 10:48:33AM -0400, Bandan Das wrote:
> Gleb Natapov <gleb@redhat.com> writes:
> 
> > On Wed, Jul 03, 2013 at 04:24:33PM +0800, Arthur Chunqi Li wrote:
> >> Hi Gleb and Paolo,
> >> When I write test cases for nested virt and found that reading/writing
> >>  IA32_FEATURE_CONTROL will be simply ignored or return 0 (in
> >> arch/x86/kvm/vmx.c) in VM. Checking this MSR will be done by some
> >> hypervisors (e.g. NOVA) and may cause error then, so it is necessary
> >> to behave right when read/write it in VM.
> >> 
> > NOVA cannot write to it and expect anything but #GP since BIOSes usually
> > lock the MSR. So I agree with Paolo about returning 5 on read and #GP on
> > write. Later we can implement locking functionality and make BIOS
> > enable/disable nested vmx.
> 
> I vaguely recalled Nadav had posted a patch related to this MSR a
> while back and found this :
> 
> http://permalink.gmane.org/gmane.comp.emulators.kvm.devel/88478
> 
> Shouldn't this work ?
> 
It should, but it needs additional Seabios patch to enabled vmx. Also
the patch is incorrectly resets MSR on SIPI. There is no point in lock
bit if it can be reset by SIPI.

> >> Are there any difficulties to handle this MSR? I have two solutions.
> >> The first one is return the value of physical CPU's and always return
> >> true when write. This is simple but may behave as if it is a VM
> >> because write to it after VMXON will not return GP exception. This
> >> solution can solve most basic problems since this MSR is not commonly
> >> used. Another solution is adding a field in VCPU to handle this MSR.
> >> This is a complex but better method.
> >> 
> >> I think I can complete this if needed.
> >> 
> >> Thanks,
> >> Arthur
> >> 
> >> --
> >> Arthur Chunqi Li
> >> Department of Computer Science
> >> School of EECS
> >> Peking University
> >> Beijing, China
> >
> > --
> > 			Gleb.
> > --
> > To unsubscribe from this list: send the line "unsubscribe kvm" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
			Gleb.

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

end of thread, other threads:[~2013-07-03 14:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-03  8:24 IA32_FEATURE_CONTROL MSR in nested virt Arthur Chunqi Li
2013-07-03  8:32 ` Paolo Bonzini
2013-07-03  8:46   ` Zhang, Yang Z
2013-07-03  8:58     ` Paolo Bonzini
2013-07-03  9:14 ` Gleb Natapov
2013-07-03  9:32   ` Gmail
2013-07-03 14:48   ` Bandan Das
2013-07-03 14:59     ` Gleb Natapov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox