* KVM: SVM: Disable Lazy FPU optimization because of regressions
@ 2007-11-18 17:14 Amit Shah
[not found] ` <200711182244.51689.amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Amit Shah @ 2007-11-18 17:14 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
>From 76204eda7e03035c16702105e78724137ecad24b Mon Sep 17 00:00:00 2001
From: Amit Shah <amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Date: Sun, 18 Nov 2007 22:42:47 +0530
Subject: [PATCH] KVM: SVM: Disable Lazy FPU optimization because of
regressions
Host FPU state is leaked into the guest FPU state. This happens
because of the lazy FPU optimization, so just reload the FPU
each time there's a VM exit/entry.
The real fix should follow soon.
This is observed in cases where fonts in a guest aren't rendered
correctly (bug 1807560).
The test program, courtesy Avi is:
double test_fpu_once()
{
int i;
double f = 0;
for (i = 0; i < 10000000; ++i)
f += 1 / (1.0 + i);
return f;
}
void test_fpu()
{
double a, b;
int runs;
runs = 0;
a = test_fpu_once();
while (1) {
b = test_fpu_once();
if (fabs(a - b) > 1e-9)
printf("error: %20.16f -> %20.16f\n", a, b);
a = b;
if (++runs % 100 == 0)
printf("runs: %8d\n", runs);
}
}
int main(int ac, char **av)
{
test_fpu();
return 0;
}
Run this on the host and the guest, both pinned to the same
host CPU.
Signed-off-by: Amit Shah <amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
---
drivers/kvm/svm.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index ea2cb83..d7c9b92 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -1600,11 +1600,11 @@ static void svm_set_cr3(struct kvm_vcpu *vcpu,
unsigned long root)
svm->vmcb->save.cr3 = root;
force_new_asid(vcpu);
- if (vcpu->fpu_active) {
- svm->vmcb->control.intercept_exceptions |= (1 << NM_VECTOR);
- svm->vmcb->save.cr0 |= X86_CR0_TS;
- vcpu->fpu_active = 0;
- }
+/* if (vcpu->fpu_active) { */
+/* svm->vmcb->control.intercept_exceptions |= (1 << NM_VECTOR); */
+/* svm->vmcb->save.cr0 |= X86_CR0_TS; */
+/* vcpu->fpu_active = 0; */
+/* } */
}
static void svm_inject_page_fault(struct kvm_vcpu *vcpu,
--
1.4.4.2
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <200711182244.51689.amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org>]
* Re: KVM: SVM: Disable Lazy FPU optimization because of regressions [not found] ` <200711182244.51689.amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org> @ 2007-11-18 17:28 ` Avi Kivity [not found] ` <47407658.1010803-atKUWr5tajBWk0Htik3J/w@public.gmane.org> 2007-11-18 18:19 ` Mike Lampard 1 sibling, 1 reply; 5+ messages in thread From: Avi Kivity @ 2007-11-18 17:28 UTC (permalink / raw) To: Amit Shah; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f Amit Shah wrote: > >From 76204eda7e03035c16702105e78724137ecad24b Mon Sep 17 00:00:00 2001 > From: Amit Shah <amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org> > Date: Sun, 18 Nov 2007 22:42:47 +0530 > Subject: [PATCH] KVM: SVM: Disable Lazy FPU optimization because of > regressions > > Host FPU state is leaked into the guest FPU state. This happens > because of the lazy FPU optimization, so just reload the FPU > each time there's a VM exit/entry. > > The real fix should follow soon. > > Applied, thanks, and: > diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c > index ea2cb83..d7c9b92 100644 > --- a/drivers/kvm/svm.c > +++ b/drivers/kvm/svm.c > @@ -1600,11 +1600,11 @@ static void svm_set_cr3(struct kvm_vcpu *vcpu, > unsigned long root) > svm->vmcb->save.cr3 = root; > force_new_asid(vcpu); > > - if (vcpu->fpu_active) { > - svm->vmcb->control.intercept_exceptions |= (1 << NM_VECTOR); > - svm->vmcb->save.cr0 |= X86_CR0_TS; > - vcpu->fpu_active = 0; > - } > +/* if (vcpu->fpu_active) { */ > +/* svm->vmcb->control.intercept_exceptions |= (1 << NM_VECTOR); */ > +/* svm->vmcb->save.cr0 |= X86_CR0_TS; */ > +/* vcpu->fpu_active = 0; */ > +/* } */ > } > > static void svm_inject_page_fault(struct kvm_vcpu *vcpu, > Changed those into a #if 0. Those comments were unsightly. -- error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <47407658.1010803-atKUWr5tajBWk0Htik3J/w@public.gmane.org>]
* Re: KVM: SVM: Disable Lazy FPU optimization because of regressions [not found] ` <47407658.1010803-atKUWr5tajBWk0Htik3J/w@public.gmane.org> @ 2007-11-18 17:32 ` Amit Shah 0 siblings, 0 replies; 5+ messages in thread From: Amit Shah @ 2007-11-18 17:32 UTC (permalink / raw) To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f; +Cc: Avi Kivity On Sunday 18 November 2007 22:58:56 Avi Kivity wrote: > Amit Shah wrote: > > diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c > > index ea2cb83..d7c9b92 100644 > > --- a/drivers/kvm/svm.c > > +++ b/drivers/kvm/svm.c > > @@ -1600,11 +1600,11 @@ static void svm_set_cr3(struct kvm_vcpu *vcpu, > > unsigned long root) > > svm->vmcb->save.cr3 = root; > > force_new_asid(vcpu); > > > > - if (vcpu->fpu_active) { > > - svm->vmcb->control.intercept_exceptions |= (1 << NM_VECTOR); > > - svm->vmcb->save.cr0 |= X86_CR0_TS; > > - vcpu->fpu_active = 0; > > - } > > +/* if (vcpu->fpu_active) { */ > > +/* svm->vmcb->control.intercept_exceptions |= (1 << NM_VECTOR); */ > > +/* svm->vmcb->save.cr0 |= X86_CR0_TS; */ > > +/* vcpu->fpu_active = 0; */ > > +/* } */ > > } > > > > static void svm_inject_page_fault(struct kvm_vcpu *vcpu, > > Changed those into a #if 0. Those comments were unsightly. Oh, I really just let emacs do it for me.. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: KVM: SVM: Disable Lazy FPU optimization because of regressions [not found] ` <200711182244.51689.amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org> 2007-11-18 17:28 ` Avi Kivity @ 2007-11-18 18:19 ` Mike Lampard [not found] ` <200711190449.39313.mike-pBbpZId3k0Zx3z9c7Zyw2w@public.gmane.org> 1 sibling, 1 reply; 5+ messages in thread From: Mike Lampard @ 2007-11-18 18:19 UTC (permalink / raw) To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f; +Cc: Avi Kivity On Mon, 19 Nov 2007 03:44:51 am Amit Shah wrote: > >From 76204eda7e03035c16702105e78724137ecad24b Mon Sep 17 00:00:00 2001 > > From: Amit Shah <amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org> > Date: Sun, 18 Nov 2007 22:42:47 +0530 > Subject: [PATCH] KVM: SVM: Disable Lazy FPU optimization because of > regressions > > Host FPU state is leaked into the guest FPU state. This happens > because of the lazy FPU optimization, so just reload the FPU > each time there's a VM exit/entry. > > The real fix should follow soon. > > This is observed in cases where fonts in a guest aren't rendered > correctly (bug 1807560). > > The test program, courtesy Avi is: > > double test_fpu_once() > { > int i; > double f = 0; > > for (i = 0; i < 10000000; ++i) > f += 1 / (1.0 + i); > return f; > } > > void test_fpu() > { > double a, b; > int runs; > > runs = 0; > a = test_fpu_once(); > while (1) { > b = test_fpu_once(); > if (fabs(a - b) > 1e-9) > printf("error: %20.16f -> %20.16f\n", a, b); > a = b; > if (++runs % 100 == 0) > printf("runs: %8d\n", runs); > } > } > > int main(int ac, char **av) > { > test_fpu(); > return 0; > } > > Run this on the host and the guest, both pinned to the same > host CPU. > > Signed-off-by: Amit Shah <amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org> > --- > drivers/kvm/svm.c | 10 +++++----- > 1 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c > index ea2cb83..d7c9b92 100644 > --- a/drivers/kvm/svm.c > +++ b/drivers/kvm/svm.c > @@ -1600,11 +1600,11 @@ static void svm_set_cr3(struct kvm_vcpu *vcpu, > unsigned long root) > svm->vmcb->save.cr3 = root; > force_new_asid(vcpu); > > - if (vcpu->fpu_active) { > - svm->vmcb->control.intercept_exceptions |= (1 << NM_VECTOR); > - svm->vmcb->save.cr0 |= X86_CR0_TS; > - vcpu->fpu_active = 0; > - } > +/* if (vcpu->fpu_active) { */ > +/* svm->vmcb->control.intercept_exceptions |= (1 << NM_VECTOR); */ > +/* svm->vmcb->save.cr0 |= X86_CR0_TS; */ > +/* vcpu->fpu_active = 0; */ > +/* } */ > } > > static void svm_inject_page_fault(struct kvm_vcpu *vcpu, This patch didnt resolve the font issues for me, however the other patch (unload FPU state) did fix it. I didnt run the test app (no compiler on the (32bit ubuntu) guest atm) but reverting this patch on my tree didnt appear to adversely affect anything. Are both patches necessary? Mike ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <200711190449.39313.mike-pBbpZId3k0Zx3z9c7Zyw2w@public.gmane.org>]
* Re: KVM: SVM: Disable Lazy FPU optimization because of regressions [not found] ` <200711190449.39313.mike-pBbpZId3k0Zx3z9c7Zyw2w@public.gmane.org> @ 2007-11-18 18:47 ` Amit Shah 0 siblings, 0 replies; 5+ messages in thread From: Amit Shah @ 2007-11-18 18:47 UTC (permalink / raw) To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f; +Cc: Mike Lampard, Avi Kivity On Sunday 18 November 2007 23:49:38 Mike Lampard wrote: > This patch didnt resolve the font issues for me, however the other patch > (unload FPU state) did fix it. I didnt run the test app (no compiler on > the (32bit ubuntu) guest atm) but reverting this patch on my tree didnt > appear to adversely affect anything. Are both patches necessary? OK, thanks for confirming, even though a different patch fixed it :-) Yes, both patches will be necessary as they fix two different things, but both cause FPU leaks. With this patch, though, the guest will run slower as we disable an optimization (because it causes a regression). ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-11-18 18:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-18 17:14 KVM: SVM: Disable Lazy FPU optimization because of regressions Amit Shah
[not found] ` <200711182244.51689.amit.shah-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-18 17:28 ` Avi Kivity
[not found] ` <47407658.1010803-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-18 17:32 ` Amit Shah
2007-11-18 18:19 ` Mike Lampard
[not found] ` <200711190449.39313.mike-pBbpZId3k0Zx3z9c7Zyw2w@public.gmane.org>
2007-11-18 18:47 ` Amit Shah
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox