x86/PV: harden guest memory accesses against speculative abuse
authorJan Beulich <jbeulich@suse.com>
Fri, 19 Feb 2021 16:19:56 +0000 (17:19 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 19 Feb 2021 16:19:56 +0000 (17:19 +0100)
commit4dc1815991420b809ce18dddfdf9c0af48944204
treea57a53476c9a37d206ff6b87b5cf5856e42e20b0
parent2d824791504f4119f04f95bafffec2e37d319c25
x86/PV: harden guest memory accesses against speculative abuse

Inspired by
https://lore.kernel.org/lkml/f12e7d3cecf41b2c29734ea45a393be21d4a8058.1597848273.git.jpoimboe@redhat.com/
and prior work in that area of x86 Linux, suppress speculation with
guest specified pointer values by suitably masking the addresses to
non-canonical space in case they fall into Xen's virtual address range.

Introduce a new Kconfig control.

Note that it is necessary in such code to avoid using "m" kind operands:
If we didn't, there would be no guarantee that the register passed to
guest_access_mask_ptr is also the (base) one used for the memory access.

As a minor unrelated change in get_unsafe_asm() the unnecessary "itype"
parameter gets dropped and the XOR on the fixup path gets changed to be
a 32-bit one in all cases: This way we avoid pointless REX.W or operand
size overrides, or writes to partial registers.

Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
xen/arch/x86/usercopy.c
xen/arch/x86/x86_64/entry.S
xen/common/Kconfig
xen/include/asm-x86/asm-defns.h
xen/include/asm-x86/uaccess.h