On Tue, Jul 3, 2012 at 6:32 AM, Rusty Russell <rusty.russell at linaro.org>wrote: > On Mon, 2 Jul 2012 14:56:49 +0200, Antonios Motakis < > a.motakis at virtualopensystems.com> wrote: > > Hello again, > > > > So I tried to get this latest patch to work (it currently crashes the > > host). Unfortunately with some debugging, it seems keeping the FPU in > guest > > state until vcpu_put is not that simple! Between a guest exit, and a > > vcpu_put following it, the host can and will try to check on FPEXC_EN. > > Really? In kernel mode? Yech :( > > As you can tell, I thought this wouldn't happen. > Unfortunately it did happen very predictably in my setup. > > If the VFP has entered a "guest state", we currently then disable the > > CP10/11 trap. A SMP Linux host might very well find FPEXC_EN enabled and > > assume it needs to save the hosts state... but the state is will access > is > > the guests! So at the very least we need to keep CP10/11 disabled. > > OK, so it saves the guest state to ti->vfp_state: we'd need to get it > from there instead of from the CPU. > > But I can't think of a good way to detect when this has happened. Can > you? > Well, even if we did think of a way to detect and handle this, I think it would probably be ugly and unmaintainable. Let's not try to pull the rug under the host's feet too much IMHO. > > > An ugly workaround maybe could be to emulate reads to FPEXC_EN, with > zero. > > This way the host kernel would just move on, until we reach vcpu_put and > > switch back to the host state. I'm looking at it, however I'm not 100% > sure > > yet it won't cause other complications, and we would then depend on > kernel > > behavior that could change without warning in the future... > > Too ugly. Just restore host state for now before we local_irq_enable(): > > if (vcpu->arch.host_vfp_saved) > __kvm_restore_host_vfp(vcpu); > > We can try for tricky and efficient later? > Yeah, but in that case we might as well revert to the previous approach of switching at __kvm_vcpu_return. Maybe we can keep the part that saves the registers in kvm_vcpu_arch instead of the stack. Maybe we should keep it straightforward for now and always switch the state on a guest exit, and later on when we try to optimize we can keep a separate structure for the host's state, so we can do lazy switching for the host as well. -Antonios -------------- next part -------------- An HTML attachment was scrubbed... URL: https://lists.cs.columbia.edu/pipermail/android-virt/attachments/20120705/2823b826/attachment.html