xen/arm: p2m: Perform local TLB invalidation on vCPU migration
authorJulien Grall <julien.grall@arm.com>
Wed, 8 Mar 2017 18:06:02 +0000 (18:06 +0000)
committerStefano Stabellini <sstabellini@kernel.org>
Tue, 14 Mar 2017 23:31:07 +0000 (16:31 -0700)
commit607ad85d85f4856fa9feba44db4e16f033862eb0
tree5e14f9cbdcd69c207c4fed4173930bee63fea2f7
parentf812de1b8b3622b2788617b43830686404125d40
xen/arm: p2m: Perform local TLB invalidation on vCPU migration

The ARM architecture allows an OS to have per-CPU page tables, as it
guarantees that TLBs never migrate from one CPU to another.

This works fine until this is done in a guest. Consider the following
scenario:
    - vcpu-0 maps P to V
    - vpcu-1 maps P' to V

If run on the same physical CPU, vcpu-1 can hit in TLBs generated by
vcpu-0 accesses, and access the wrong physical page.

The solution to this is to keep a per-p2m map of which vCPU ran the last
on each given pCPU and invalidate local TLBs if two vPCUs from the same
VM run on the same CPU.

Unfortunately it is not possible to allocate per-cpu variable on the
fly. So for now the size of the array is NR_CPUS, this is fine because
we still have space in the structure domain. We may want to add an
helper to allocate per-cpu variable in the future.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/p2m.c
xen/include/asm-arm/p2m.h