All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Some KVM fixes
@ 2011-04-18  9:42 Joerg Roedel
  2011-04-18  9:42 ` [PATCH 1/2] KVM: SVM: Fix nested sel_cr0 intercept path with decode-assists Joerg Roedel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Joerg Roedel @ 2011-04-18  9:42 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm

Hi,

these two patches fix one issue introduced with the recent
emulator-intercept code (the issue was there before too, but
hidden by other workaround code which was removed in the
mentioned patch-set).
The second patch fixes a problem introduced with the tsc-scaling
patch-set where the TSC was not usable anymore after a
guest-reboot.
All-in-all, these fixes are no -stable material.

Regards,

	Joerg

Diffstat:

 arch/x86/include/asm/kvm_host.h |    1 -
 arch/x86/kvm/svm.c              |    3 +++
 arch/x86/kvm/x86.c              |    2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

Shortlog:

Joerg Roedel (2):
      KVM: SVM: Fix nested sel_cr0 intercept path with decode-assists
      KVM: X86: Update last_guest_tsc in vcpu_put




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

* [PATCH 1/2] KVM: SVM: Fix nested sel_cr0 intercept path with decode-assists
  2011-04-18  9:42 [PATCH 0/2] Some KVM fixes Joerg Roedel
@ 2011-04-18  9:42 ` Joerg Roedel
  2011-04-18  9:42 ` [PATCH 2/2] KVM: X86: Update last_guest_tsc in vcpu_put Joerg Roedel
  2011-04-20  8:28 ` [PATCH 0/2] Some KVM fixes Avi Kivity
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2011-04-18  9:42 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, Joerg Roedel

This patch fixes a bug in the nested-svm path when
decode-assists is available on the machine. After a
selective-cr0 intercept is detected the rip is advanced
unconditionally. This causes the l1-guest to continue
running with an l2-rip.
This bug was with the sel_cr0 unit-test on decode-assists
capable hardware.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kvm/svm.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index a6bf2ad..de4bba9 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2799,6 +2799,9 @@ static int cr_interception(struct vcpu_svm *svm)
 		case 0:
 			if (!check_selective_cr0_intercepted(svm, val))
 				err = kvm_set_cr0(&svm->vcpu, val);
+			else
+				return 1;
+
 			break;
 		case 3:
 			err = kvm_set_cr3(&svm->vcpu, val);
-- 
1.7.1



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

* [PATCH 2/2] KVM: X86: Update last_guest_tsc in vcpu_put
  2011-04-18  9:42 [PATCH 0/2] Some KVM fixes Joerg Roedel
  2011-04-18  9:42 ` [PATCH 1/2] KVM: SVM: Fix nested sel_cr0 intercept path with decode-assists Joerg Roedel
@ 2011-04-18  9:42 ` Joerg Roedel
  2011-04-20  8:28 ` [PATCH 0/2] Some KVM fixes Avi Kivity
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2011-04-18  9:42 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, Joerg Roedel

The last_guest_tsc is used in vcpu_load to adjust the
tsc_offset since tsc-scaling is merged. So the
last_guest_tsc needs to be updated in vcpu_put instead of
the the last_host_tsc. This is fixed with this patch.

Reported-by: Jan Kiszka <jan.kiszka@web.de>
Tested-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/include/asm/kvm_host.h |    1 -
 arch/x86/kvm/x86.c              |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index bd57639..d7282ef 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -391,7 +391,6 @@ struct kvm_vcpu_arch {
 	unsigned int hw_tsc_khz;
 	unsigned int time_offset;
 	struct page *time_page;
-	u64 last_host_tsc;
 	u64 last_guest_tsc;
 	u64 last_kernel_ns;
 	u64 last_tsc_nsec;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1d5a7f4..d8277aa 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2146,7 +2146,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
 {
 	kvm_x86_ops->vcpu_put(vcpu);
 	kvm_put_guest_fpu(vcpu);
-	vcpu->arch.last_host_tsc = native_read_tsc();
+	kvm_get_msr(vcpu, MSR_IA32_TSC, &vcpu->arch.last_guest_tsc);
 }
 
 static int is_efer_nx(void)
-- 
1.7.1



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

* Re: [PATCH 0/2] Some KVM fixes
  2011-04-18  9:42 [PATCH 0/2] Some KVM fixes Joerg Roedel
  2011-04-18  9:42 ` [PATCH 1/2] KVM: SVM: Fix nested sel_cr0 intercept path with decode-assists Joerg Roedel
  2011-04-18  9:42 ` [PATCH 2/2] KVM: X86: Update last_guest_tsc in vcpu_put Joerg Roedel
@ 2011-04-20  8:28 ` Avi Kivity
  2 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2011-04-20  8:28 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Marcelo Tosatti, kvm

On 04/18/2011 12:42 PM, Joerg Roedel wrote:
> Hi,
>
> these two patches fix one issue introduced with the recent
> emulator-intercept code (the issue was there before too, but
> hidden by other workaround code which was removed in the
> mentioned patch-set).
> The second patch fixes a problem introduced with the tsc-scaling
> patch-set where the TSC was not usable anymore after a
> guest-reboot.
> All-in-all, these fixes are no -stable material.

Applied, thanks.

-- 
error compiling committee.c: too many arguments to function


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

end of thread, other threads:[~2011-04-20  8:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-18  9:42 [PATCH 0/2] Some KVM fixes Joerg Roedel
2011-04-18  9:42 ` [PATCH 1/2] KVM: SVM: Fix nested sel_cr0 intercept path with decode-assists Joerg Roedel
2011-04-18  9:42 ` [PATCH 2/2] KVM: X86: Update last_guest_tsc in vcpu_put Joerg Roedel
2011-04-20  8:28 ` [PATCH 0/2] Some KVM fixes Avi Kivity

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.