Skip to contentSkip to conversation

Question on corruption of host/guest vfp switch hyp function

DISCUSSION Mario Smarduch 1 participant 1 message Jun 19, 2015 KVM arm64

lore
Share & tools
lore
#0 lore raw

I created a HYP function and call it from kvm_arch_vcpu_put().
It dies in restore_vfp_state right at the 'ldm' call.

Is the calling convention bad? Or anything else? vcpu structure is corrupted right after that instruction.

I expanded the restore_vfp_state macro below, without the ldm the guest boots (of course vfp restore is not complete).

I'm running this on FastModels 9.x

Thanks,
Mario

+ENTRY(__kvm_restore_host_vfp_state)
+ push {r3, r7}
+

+       mov     r1, #0
+       str     r1, [r0, #VCPU_VFP_SAVED]
+
+       VFPFMRX r1, FPEXC
+       push {r1}
+       orr     r6, r2, #FPEXC_EN
+       VFPFMXR FPEXC, r6

+
+ add r7, r0, #VCPU_VFP_GUEST
+ store_vfp_state r7
+

+       add      r7, r0, #VCPU_VFP_HOST
+       ldr      r7, [r7]
+       restore_vfp_state r7
+
+       pop {r1}
+       VFPFMXR FPEXC, r1
+       pop {r3, r7}
+       bx      lr

+ENDPROC(__kvm_restore_host_vfp_state)

+       LDC     p11, cr0, [r7],#32*4
+       MRC     p10, 7, r6, cr7, cr0, 0
+       and     r6, r6, #(0xf << 0)
+       cmp     r6, #2
+       @ldceql  p11, cr0, [r7],#32*4
+       @addne   r7, r7, #32*4
+       @dsb
+       @sb
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Corruption here and dies <<<<<<<

+ ldm r7, {r2-r5}