x86/xpti: Don't leak TSS-adjacent percpu data via Meltdown
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 23 Sep 2019 12:37:46 +0000 (14:37 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 23 Sep 2019 12:37:46 +0000 (14:37 +0200)
commitda235ee4e738a1182f4360bcb38ee3bfefb553ef
tree057654a9e3b1d401d37d77f8d5e66a892678a67d
parent32bdae275064da0eb745dd371c27088c0ad80088
x86/xpti: Don't leak TSS-adjacent percpu data via Meltdown

The XPTI work restricted the visibility of most of memory, but missed a few
aspects when it came to the TSS.

Given that the TSS is just an object in percpu data, the 4k mapping for it
created in setup_cpu_root_pgt() maps adjacent percpu data, making it all
leakable via Meltdown, even when XPTI is in use.

Furthermore, no care is taken to check that the TSS doesn't cross a page
boundary.  As it turns out, struct tss_struct is aligned on its size which
does prevent it straddling a page boundary.

Rework the TSS types while making this change.  Rename tss_struct to tss64, to
mirror the existing tss32 structure we have in HVM's Tast Switch logic.  Drop
tss64's alignment and __cacheline_filler[] field.

Introduce tss_page which contains a single tss64 and keeps the rest of the
page clear, so no adjacent data can be leaked.  Move the definition from
setup.c to traps.c, which is a more appropriate place for it to live.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
master commit: 7888440625617693487495a7842e6a991ead2647
master date: 2019-08-12 14:10:09 +0100
xen/arch/x86/cpu/common.c
xen/arch/x86/hvm/vmx/vmcs.c
xen/arch/x86/setup.c
xen/arch/x86/smpboot.c
xen/arch/x86/traps.c
xen/include/asm-x86/processor.h