kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: Don't allow lmsw to clear cr0.pe
@ 2010-05-11 21:28 Avi Kivity
  2010-05-11 22:13 ` Andy Walls
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Avi Kivity @ 2010-05-11 21:28 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm, Andy Walls

The current lmsw implementation allows the guest to clear cr0.pe, contrary
to the manual, which breaks EMM386.EXE.

Fix by ORing the old cr0.pe with lmsw's operand.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/x86.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index cd8a606..a40170c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -462,7 +462,7 @@ EXPORT_SYMBOL_GPL(kvm_set_cr0);
 
 void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw)
 {
-	kvm_set_cr0(vcpu, kvm_read_cr0_bits(vcpu, ~0x0ful) | (msw & 0x0f));
+	kvm_set_cr0(vcpu, kvm_read_cr0_bits(vcpu, ~0x0eul) | (msw & 0x0f));
 }
 EXPORT_SYMBOL_GPL(kvm_lmsw);
 
-- 
1.7.0.4


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

* Re: [PATCH] KVM: Don't allow lmsw to clear cr0.pe
  2010-05-11 21:28 [PATCH] KVM: Don't allow lmsw to clear cr0.pe Avi Kivity
@ 2010-05-11 22:13 ` Andy Walls
  2010-05-12 16:18 ` Andy Walls
  2010-05-13  3:31 ` Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Walls @ 2010-05-11 22:13 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, kvm

On Wed, 2010-05-12 at 00:28 +0300, Avi Kivity wrote:
> The current lmsw implementation allows the guest to clear cr0.pe, contrary
> to the manual, which breaks EMM386.EXE.
> 
> Fix by ORing the old cr0.pe with lmsw's operand.
> 
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  arch/x86/kvm/x86.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index cd8a606..a40170c 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -462,7 +462,7 @@ EXPORT_SYMBOL_GPL(kvm_set_cr0);
>  
>  void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw)
>  {
> -	kvm_set_cr0(vcpu, kvm_read_cr0_bits(vcpu, ~0x0ful) | (msw & 0x0f));
> +	kvm_set_cr0(vcpu, kvm_read_cr0_bits(vcpu, ~0x0eul) | (msw & 0x0f));
>  }
>  EXPORT_SYMBOL_GPL(kvm_lmsw);
>  

Cool.  I will build a kernel and test tomorrow.

Regards,
Andy


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

* Re: [PATCH] KVM: Don't allow lmsw to clear cr0.pe
  2010-05-11 21:28 [PATCH] KVM: Don't allow lmsw to clear cr0.pe Avi Kivity
  2010-05-11 22:13 ` Andy Walls
@ 2010-05-12 16:18 ` Andy Walls
  2010-05-13  3:31 ` Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Walls @ 2010-05-12 16:18 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, kvm

On Wed, 2010-05-12 at 00:28 +0300, Avi Kivity wrote:
> The current lmsw implementation allows the guest to clear cr0.pe, contrary
> to the manual, which breaks EMM386.EXE.
> 
> Fix by ORing the old cr0.pe with lmsw's operand.
> 
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  arch/x86/kvm/x86.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index cd8a606..a40170c 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -462,7 +462,7 @@ EXPORT_SYMBOL_GPL(kvm_set_cr0);
>  
>  void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw)
>  {
> -	kvm_set_cr0(vcpu, kvm_read_cr0_bits(vcpu, ~0x0ful) | (msw & 0x0f));
> +	kvm_set_cr0(vcpu, kvm_read_cr0_bits(vcpu, ~0x0eul) | (msw & 0x0f));
>  }
>  EXPORT_SYMBOL_GPL(kvm_lmsw);
>  

This patch works for me.  The old programs I have that use the DOS/4GW
extender (http://www.tenberry.com/) runtime no longer hanging the MS-DOS
6.22 guest when EMM386.EXE is loaded and the "set_cr0: #GP..." message
is no longer filling the logs.

:)


Now I have a different problem.  dmesg is filling with
"skip_emulated_instruction: NOP" messages.  As I investigate further, I
unfortunately found that RHEL 5 has a somewhat dated kvm package:

ftp://ftp.redhat.com/redhat/linux/enterprise/5Client/en/os/SRPMS/kvm-83-164.el5.src.rpm

that looks to be based on a KVM snapshot from around May of last year.
It appears to missing some recent patches in regard to
skip_emulated_instruction().  :(

Oh well.  I'll try qemu without KVM hardware acceleration.

Thanks for the fast response on the LMSW patch.

Regards,
Andy




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

* Re: [PATCH] KVM: Don't allow lmsw to clear cr0.pe
  2010-05-11 21:28 [PATCH] KVM: Don't allow lmsw to clear cr0.pe Avi Kivity
  2010-05-11 22:13 ` Andy Walls
  2010-05-12 16:18 ` Andy Walls
@ 2010-05-13  3:31 ` Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Marcelo Tosatti @ 2010-05-13  3:31 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, Andy Walls

On Wed, May 12, 2010 at 12:28:44AM +0300, Avi Kivity wrote:
> The current lmsw implementation allows the guest to clear cr0.pe, contrary
> to the manual, which breaks EMM386.EXE.
> 
> Fix by ORing the old cr0.pe with lmsw's operand.
> 
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  arch/x86/kvm/x86.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.


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

end of thread, other threads:[~2010-05-13  4:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-11 21:28 [PATCH] KVM: Don't allow lmsw to clear cr0.pe Avi Kivity
2010-05-11 22:13 ` Andy Walls
2010-05-12 16:18 ` Andy Walls
2010-05-13  3:31 ` Marcelo Tosatti

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