On 05/21/2012 05:49 AM, Rusty Russell wrote: > On Sat, 17 Mar 2012 09:59:23 +0100, Antonios Motakis<a.motakis at virtualopensystems.com> wrote: >> Applies to commit 827ee5bffde826336c4a7f33109347c77a2cbbcf of the >> latest kvm-a15-v7 branch. >> >> This patch allows to safely run guests that use the VFP and NEON >> floating point extensions. When we switch to a guest, we save >> the host's state (registers with floating point data, configuration >> registers) and load those used by the guest. We can also handle >> versions of the extensions with 16 or 32 double registers, and >> also the registers introduced by the Common VFP Subarchitecture, as >> defined in the ARM Architecture Reference Manual, Issue C. >> >> Possible future improvements include letting QEMU fetch a copy of the >> registers, and lazy switching of the registers only when they are >> actually used. > I re-read this patch, and I don't think it's right: > >> +.macro store_vfp_state vcpu=0, vcpup >> + mrc p10, 7, r2, cr8, cr0, 0 @ FPEXC >> + tst r2, #FPEXC_EN @ Check if floating point is enabled >> + beq 1f > The guest may turn FPEXEC_EN off, but that doesn't mean the state isn't > important. In particular, a (non-SMP) Linux ARM guest will turn the > FPEXEC_EN bit off on context switch, without saving the contents. > > Similar logic applied to the host: we might have turned FPEXEC_EN off, > but that doesn't mean the contents of the registers aren't worth saving. > > Cheers, > Rusty. My first attempted implementation tried to save/restore state regardless of FPEXC_EN. However, it turned out that when FPEXC_EN is 0, most VFP instructions will cause an undefined instruction trap (ARM arm p. B1-1225) so the code wouldn't work. Is the hardware supposed to preserve state even when the FPU extensions are disabled? Best regards, Antonios