x86/hvm/viridian: fix the TLB flush hypercall
authorPaul Durrant <paul.durrant@citrix.com>
Thu, 17 Mar 2016 12:49:06 +0000 (13:49 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 17 Mar 2016 12:49:06 +0000 (13:49 +0100)
commit65f1fe7fcea6cdbbc7859707929cee971d65f30d
tree33743a2d6f75f87aaa56f7b8beb07762885beb4f
parent1e4faa2d25639856f776460e8cbbe2b48843dd20
x86/hvm/viridian: fix the TLB flush hypercall

Commit b38d426a "flush remote tlbs by hypercall" add support to allow
Windows to request flush of remote TLB via hypercall rather than IPI.
Unfortunately it seems that this code was broken in a couple of ways:

1) The allocation of the per-vcpu ipi mask is gated on whether the
   domain has viridian features enabled but the call to allocate is
   made before the toolstack has enabled those features. This results
   in a NULL pointer dereference.

2) One of the flush hypercall variants is a rep op, but the code
   does not update the output data with the reps completed. Hence the
   guest will spin repeatedly making the hypercall because it believes
   it has uncompleted reps.

This patch fixes both of these issues as follows:

1) The ipi mask need only be per-pcpu so it is made a per-pcpu static
   to avoid the need for allocation.

2) The rep complete count is updated to the rep count since the single
   flush that Xen does covers all reps anyway.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/viridian.c
xen/include/asm-x86/hvm/viridian.h