]> xenbits.xensource.com Git - xen.git/commit
x86: Always have CR4.PKE set in HVM context
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 29 Apr 2021 13:28:43 +0000 (14:28 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 30 Apr 2021 16:07:29 +0000 (17:07 +0100)
commit95aaafb5e2a09cad2ab42223e4aa55f88833ef3c
tree84019918b1f108ad6fb520ad31e72a1c2abfd525
parentb8e53a81ba538849b98b0d417436f8be653fa1ff
x86: Always have CR4.PKE set in HVM context

The sole user of read_pkru() is the emulated pagewalk, and guarded behind
guest_pku_enabled() which restricts the path to HVM (hap, even) context only.

The commentary in read_pkru() concerning _PAGE_GNTTAB overlapping with
_PAGE_PKEY_BITS is only applicable to PV guests.

The context switch path, via write_ptbase() unconditionally writes CR4 on any
context switch.

Therefore, we can guarantee to separate CR4.PKE between PV and HVM context at
no extra cost.  Set PKE in mmu_cr4_features on boot, so it becomes set in HVM
context, and clear it in pv_make_cr4().

Rename read_pkru() to rdpkru() now that it is a simple wrapper around the
instruction.  This saves two CR4 writes on every pagewalk, which typically
occur more than one per emulation.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/mm/guest_walk.c
xen/arch/x86/pv/domain.c
xen/arch/x86/setup.c
xen/include/asm-x86/processor.h