* [PATCH] KVM: x86 emulator: fix xchg instruction emulation
@ 2010-07-14 5:15 Wei Yongjun
2010-07-14 8:35 ` Gleb Natapov
2010-07-14 16:37 ` Marcelo Tosatti
0 siblings, 2 replies; 5+ messages in thread
From: Wei Yongjun @ 2010-07-14 5:15 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
If the destination is a memory operand and the memory
cannot map to a valid page, the xchg instruction emulation
will fail. If so, we should emulate exchange as write
to fix it.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
arch/x86/kvm/x86.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index d94811e..ac63f6f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3560,6 +3560,8 @@ static int emulator_cmpxchg_emulated(unsigned long addr,
goto emul_write;
page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT);
+ if (is_error_page(page))
+ goto emul_write;
kaddr = kmap_atomic(page, KM_USER0);
kaddr += offset_in_page(gpa);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: x86 emulator: fix xchg instruction emulation
2010-07-14 5:15 [PATCH] KVM: x86 emulator: fix xchg instruction emulation Wei Yongjun
@ 2010-07-14 8:35 ` Gleb Natapov
2010-07-14 16:37 ` Marcelo Tosatti
1 sibling, 0 replies; 5+ messages in thread
From: Gleb Natapov @ 2010-07-14 8:35 UTC (permalink / raw)
To: Wei Yongjun; +Cc: Avi Kivity, kvm
On Wed, Jul 14, 2010 at 01:15:09PM +0800, Wei Yongjun wrote:
> If the destination is a memory operand and the memory
> cannot map to a valid page, the xchg instruction emulation
> will fail. If so, we should emulate exchange as write
> to fix it.
>
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Acked-by: Gleb Natapov <gleb@redhat.com>
Without this patch locked instruction does not work on io regions.
They don't just fail, they stuck in endless loop.
> ---
> arch/x86/kvm/x86.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index d94811e..ac63f6f 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3560,6 +3560,8 @@ static int emulator_cmpxchg_emulated(unsigned long addr,
> goto emul_write;
>
> page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT);
> + if (is_error_page(page))
> + goto emul_write;
>
> kaddr = kmap_atomic(page, KM_USER0);
> kaddr += offset_in_page(gpa);
> --
> 1.7.0.4
>
>
> --
> 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] 5+ messages in thread
* Re: [PATCH] KVM: x86 emulator: fix xchg instruction emulation
2010-07-14 5:15 [PATCH] KVM: x86 emulator: fix xchg instruction emulation Wei Yongjun
2010-07-14 8:35 ` Gleb Natapov
@ 2010-07-14 16:37 ` Marcelo Tosatti
2010-07-15 0:51 ` [PATCHv2] " Wei Yongjun
1 sibling, 1 reply; 5+ messages in thread
From: Marcelo Tosatti @ 2010-07-14 16:37 UTC (permalink / raw)
To: Wei Yongjun; +Cc: Avi Kivity, kvm
On Wed, Jul 14, 2010 at 01:15:09PM +0800, Wei Yongjun wrote:
> If the destination is a memory operand and the memory
> cannot map to a valid page, the xchg instruction emulation
> will fail. If so, we should emulate exchange as write
> to fix it.
>
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> ---
> arch/x86/kvm/x86.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index d94811e..ac63f6f 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3560,6 +3560,8 @@ static int emulator_cmpxchg_emulated(unsigned long addr,
> goto emul_write;
>
> page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT);
> + if (is_error_page(page))
> + goto emul_write;
Forgot to release page.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCHv2] KVM: x86 emulator: fix xchg instruction emulation
2010-07-14 16:37 ` Marcelo Tosatti
@ 2010-07-15 0:51 ` Wei Yongjun
2010-07-16 2:05 ` Marcelo Tosatti
0 siblings, 1 reply; 5+ messages in thread
From: Wei Yongjun @ 2010-07-15 0:51 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: Avi Kivity, kvm
If the destination is a memory operand and the memory cannot
map to a valid page, the xchg instruction emulation and locked
instruction will not work on io regions and stuck in endless
loop. We should emulate exchange as write to fix it.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Acked-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/x86.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 86c8102..84bfb51 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3562,6 +3562,10 @@ static int emulator_cmpxchg_emulated(unsigned long addr,
goto emul_write;
page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT);
+ if (is_error_page(page)) {
+ kvm_release_page_clean(page);
+ goto emul_write;
+ }
kaddr = kmap_atomic(page, KM_USER0);
kaddr += offset_in_page(gpa);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCHv2] KVM: x86 emulator: fix xchg instruction emulation
2010-07-15 0:51 ` [PATCHv2] " Wei Yongjun
@ 2010-07-16 2:05 ` Marcelo Tosatti
0 siblings, 0 replies; 5+ messages in thread
From: Marcelo Tosatti @ 2010-07-16 2:05 UTC (permalink / raw)
To: Wei Yongjun; +Cc: Avi Kivity, kvm
On Thu, Jul 15, 2010 at 08:51:58AM +0800, Wei Yongjun wrote:
> If the destination is a memory operand and the memory cannot
> map to a valid page, the xchg instruction emulation and locked
> instruction will not work on io regions and stuck in endless
> loop. We should emulate exchange as write to fix it.
>
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> Acked-by: Gleb Natapov <gleb@redhat.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-07-16 2:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-14 5:15 [PATCH] KVM: x86 emulator: fix xchg instruction emulation Wei Yongjun
2010-07-14 8:35 ` Gleb Natapov
2010-07-14 16:37 ` Marcelo Tosatti
2010-07-15 0:51 ` [PATCHv2] " Wei Yongjun
2010-07-16 2:05 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox