kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fixed KVM problems with old DOS programs. Compatibility can be forced by module parameter.
@ 2015-11-04 19:33 Gerhard Wiesinger
  2015-11-04 21:27 ` Paolo Bonzini
  0 siblings, 1 reply; 7+ messages in thread
From: Gerhard Wiesinger @ 2015-11-04 19:33 UTC (permalink / raw)
  To: kvm

Signed-off-by: Gerhard Wiesinger <lists@wiesinger.com>
---
  arch/x86/kvm/svm.c | 7 +++++++
  1 file changed, 7 insertions(+)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 2f9ed1f..e0b00fc 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -198,6 +198,10 @@ static bool npt_enabled;
  static int npt = true;
  module_param(npt, int, S_IRUGO);
  +/* allow backward compatibility with e.g. old DOS application */
+static int npt_task_switch_emulation = true;
+module_param(npt_task_switch_emulation, int, S_IRUGO);
+
  /* allow nested virtualization in KVM/SVM */
  static int nested = true;
  module_param(nested, int, S_IRUGO);
@@ -1177,6 +1181,9 @@ static void init_vmcb(struct vcpu_svm *svm, bool 
init_event)
  	if (npt_enabled) {
  		/* Setup VMCB for Nested Paging */
  		control->nested_ctl = 1;
+		if (!npt_task_switch_emulation) {
+			clr_intercept(svm, INTERCEPT_TASK_SWITCH);
+		}
  		clr_intercept(svm, INTERCEPT_INVLPG);
  		clr_exception_intercept(svm, PF_VECTOR);
  		clr_cr_intercept(svm, INTERCEPT_CR3_READ);
-- 
2.4.3


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

* Re: [PATCH] Fixed KVM problems with old DOS programs. Compatibility can be forced by module parameter.
  2015-11-04 19:33 [PATCH] Fixed KVM problems with old DOS programs. Compatibility can be forced by module parameter Gerhard Wiesinger
@ 2015-11-04 21:27 ` Paolo Bonzini
  2015-11-04 21:33   ` Gerhard Wiesinger
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2015-11-04 21:27 UTC (permalink / raw)
  To: Gerhard Wiesinger, kvm



On 04/11/2015 20:33, Gerhard Wiesinger wrote:
> Signed-off-by: Gerhard Wiesinger <lists@wiesinger.com>
> ---
>  arch/x86/kvm/svm.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 2f9ed1f..e0b00fc 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -198,6 +198,10 @@ static bool npt_enabled;
>  static int npt = true;
>  module_param(npt, int, S_IRUGO);
>  +/* allow backward compatibility with e.g. old DOS application */
> +static int npt_task_switch_emulation = true;
> +module_param(npt_task_switch_emulation, int, S_IRUGO);
> +
>  /* allow nested virtualization in KVM/SVM */
>  static int nested = true;
>  module_param(nested, int, S_IRUGO);
> @@ -1177,6 +1181,9 @@ static void init_vmcb(struct vcpu_svm *svm, bool
> init_event)
>      if (npt_enabled) {
>          /* Setup VMCB for Nested Paging */
>          control->nested_ctl = 1;
> +        if (!npt_task_switch_emulation) {
> +            clr_intercept(svm, INTERCEPT_TASK_SWITCH);
> +        }
>          clr_intercept(svm, INTERCEPT_INVLPG);
>          clr_exception_intercept(svm, PF_VECTOR);
>          clr_cr_intercept(svm, INTERCEPT_CR3_READ);

What is the problem you are seeing?  KVM can emulate task switches; the
intercept is set here because of a processor erratum that can mess them
up even though, in theory, AMD supports task switching from guest mode.

Paolo

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

* Re: [PATCH] Fixed KVM problems with old DOS programs. Compatibility can be forced by module parameter.
  2015-11-04 21:27 ` Paolo Bonzini
@ 2015-11-04 21:33   ` Gerhard Wiesinger
  2015-11-04 22:04     ` Paolo Bonzini
  0 siblings, 1 reply; 7+ messages in thread
From: Gerhard Wiesinger @ 2015-11-04 21:33 UTC (permalink / raw)
  To: Paolo Bonzini, kvm

On 04.11.2015 22:27, Paolo Bonzini wrote:
>
> On 04/11/2015 20:33, Gerhard Wiesinger wrote:
>> Signed-off-by: Gerhard Wiesinger <lists@wiesinger.com>
>> ---
>>   arch/x86/kvm/svm.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
>> index 2f9ed1f..e0b00fc 100644
>> --- a/arch/x86/kvm/svm.c
>> +++ b/arch/x86/kvm/svm.c
>> @@ -198,6 +198,10 @@ static bool npt_enabled;
>>   static int npt = true;
>>   module_param(npt, int, S_IRUGO);
>>   +/* allow backward compatibility with e.g. old DOS application */
>> +static int npt_task_switch_emulation = true;
>> +module_param(npt_task_switch_emulation, int, S_IRUGO);
>> +
>>   /* allow nested virtualization in KVM/SVM */
>>   static int nested = true;
>>   module_param(nested, int, S_IRUGO);
>> @@ -1177,6 +1181,9 @@ static void init_vmcb(struct vcpu_svm *svm, bool
>> init_event)
>>       if (npt_enabled) {
>>           /* Setup VMCB for Nested Paging */
>>           control->nested_ctl = 1;
>> +        if (!npt_task_switch_emulation) {
>> +            clr_intercept(svm, INTERCEPT_TASK_SWITCH);
>> +        }
>>           clr_intercept(svm, INTERCEPT_INVLPG);
>>           clr_exception_intercept(svm, PF_VECTOR);
>>           clr_cr_intercept(svm, INTERCEPT_CR3_READ);
> What is the problem you are seeing?  KVM can emulate task switches; the
> intercept is set here because of a processor erratum that can mess them
> up even though, in theory, AMD supports task switching from guest mode.

See old thread:
https://lists.nongnu.org/archive/html/qemu-devel/2012-04/msg01506.html

Ciao,
Gerhard


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

* Re: [PATCH] Fixed KVM problems with old DOS programs. Compatibility can be forced by module parameter.
  2015-11-04 21:33   ` Gerhard Wiesinger
@ 2015-11-04 22:04     ` Paolo Bonzini
  2015-11-05 16:07       ` Gerhard Wiesinger
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2015-11-04 22:04 UTC (permalink / raw)
  To: Gerhard Wiesinger, kvm



On 04/11/2015 22:33, Gerhard Wiesinger wrote:
>>>
>> What is the problem you are seeing?  KVM can emulate task switches; the
>> intercept is set here because of a processor erratum that can mess them
>> up even though, in theory, AMD supports task switching from guest mode.
> 
> See old thread:
> https://lists.nongnu.org/archive/html/qemu-devel/2012-04/msg01506.html

Can you obtain the traces you were asked for at the time?

Paolo

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

* Re: [PATCH] Fixed KVM problems with old DOS programs. Compatibility can be forced by module parameter.
  2015-11-04 22:04     ` Paolo Bonzini
@ 2015-11-05 16:07       ` Gerhard Wiesinger
  2015-11-05 16:15         ` Paolo Bonzini
  0 siblings, 1 reply; 7+ messages in thread
From: Gerhard Wiesinger @ 2015-11-05 16:07 UTC (permalink / raw)
  To: Paolo Bonzini, kvm

On 04.11.2015 23:04, Paolo Bonzini wrote:
>
> On 04/11/2015 22:33, Gerhard Wiesinger wrote:
>>> What is the problem you are seeing?  KVM can emulate task switches; the
>>> intercept is set here because of a processor erratum that can mess them
>>> up even though, in theory, AMD supports task switching from guest mode.
>> See old thread:
>> https://lists.nongnu.org/archive/html/qemu-devel/2012-04/msg01506.html
> Can you obtain the traces you were asked for at the time?

./trace-cmd record -b 20000 -e kvm
./trace-cmd report | grep -i task_switch
  qemu-system-x86-6024  [001] 792774.719297: kvm_exit: reason 
task_switch rip 0x4883 info 158 4000000000

But I can't interpret it. But I know my patch works well. Since it is 
just a module parameter it is fully backward compatible by default and 
because of the one liner no side effects are possible. So a intergration 
would be good.

Ciao,
Gerhard


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

* Re: [PATCH] Fixed KVM problems with old DOS programs. Compatibility can be forced by module parameter.
  2015-11-05 16:07       ` Gerhard Wiesinger
@ 2015-11-05 16:15         ` Paolo Bonzini
  2015-11-05 16:19           ` Paolo Bonzini
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2015-11-05 16:15 UTC (permalink / raw)
  To: Gerhard Wiesinger, kvm



On 05/11/2015 17:07, Gerhard Wiesinger wrote:
>>
> 
> ./trace-cmd record -b 20000 -e kvm
> ./trace-cmd report | grep -i task_switch
>  qemu-system-x86-6024  [001] 792774.719297: kvm_exit: reason task_switch
> rip 0x4883 info 158 4000000000

0x158 is the segment selector of the incoming TSS, and the task switch
was caused by a far jump.

> But I can't interpret it.

Neither can I; you have to send the whole trace.

> But I know my patch works well. Since it is
> just a module parameter it is fully backward compatible by default and
> because of the one liner no side effects are possible. So a intergration
> would be good.

It's also papering over a bug, and likely the bug still triggers on
Intel systems.  So it's not acceptable.

Can you provide reproduction instructions please?

Paolo

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

* Re: [PATCH] Fixed KVM problems with old DOS programs. Compatibility can be forced by module parameter.
  2015-11-05 16:15         ` Paolo Bonzini
@ 2015-11-05 16:19           ` Paolo Bonzini
  0 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2015-11-05 16:19 UTC (permalink / raw)
  To: Gerhard Wiesinger, kvm



On 05/11/2015 17:15, Paolo Bonzini wrote:
> 
> 
> On 05/11/2015 17:07, Gerhard Wiesinger wrote:
>>>
>>
>> ./trace-cmd record -b 20000 -e kvm
>> ./trace-cmd report | grep -i task_switch
>>  qemu-system-x86-6024  [001] 792774.719297: kvm_exit: reason task_switch
>> rip 0x4883 info 158 4000000000
> 
> 0x158 is the segment selector of the incoming TSS, and the task switch
> was caused by a far jump.
> 
>> But I can't interpret it.
> 
> Neither can I; you have to send the whole trace.
> 
>> But I know my patch works well. Since it is
>> just a module parameter it is fully backward compatible by default and
>> because of the one liner no side effects are possible. So a intergration
>> would be good.
> 
> It's also papering over a bug, and likely the bug still triggers on
> Intel systems.  So it's not acceptable.
> 
> Can you provide reproduction instructions please?

At the very least, does it reproduce without KVM?

Paolo

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

end of thread, other threads:[~2015-11-05 16:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-04 19:33 [PATCH] Fixed KVM problems with old DOS programs. Compatibility can be forced by module parameter Gerhard Wiesinger
2015-11-04 21:27 ` Paolo Bonzini
2015-11-04 21:33   ` Gerhard Wiesinger
2015-11-04 22:04     ` Paolo Bonzini
2015-11-05 16:07       ` Gerhard Wiesinger
2015-11-05 16:15         ` Paolo Bonzini
2015-11-05 16:19           ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).