[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86: Always have CR4.PKE set in HVM context



On 30.04.2021 00:12, Andrew Cooper wrote:
> 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@xxxxxxxxxx>

The changes looks perfectly fine to me, but I still feel urged to make
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
conditional upon my "x86emul: support RDPKRU/WRPKRU" (submitted exactly
half a year ago) going in first, unless there were to be review comments
making extensive rework necessary. In the absence of such review
feedback, I consider it pretty inappropriate for me to do rebasing work
(no matter that this would be largely mechanical afaics) here for a
patch which has been pending and effectively ignored for so long. (The
main thing that immediately struck me as odd was "The sole user of
read_pkru() is ...".)

I'm sorry, Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.