Re: [PATCH v4 4/5] KVM: MMU: Add support for PKS emulation

From: Paolo Bonzini
Date: Fri Feb 05 2021 - 04:26:11 EST


On 05/02/21 09:37, Chenyi Qiang wrote:
|In addition to the pkey check for user pages, advertise pkr_mask also to cache the conditions where protection key checks for supervisor pages are needed. Add CR4_PKS in mmu_role_bits to track the pkr_mask update on a per-mmu basis. In original cache conditions of pkr_mask, U/S bit in page tables is a judgement condition and replace the PFEC.RSVD in page fault error code to form the index of 16 domains. PKS support would extend the U/S bits (if U/S=0, PKS check required). It adds an additional check for cr4_pke/cr4_pks to ensure the necessity and distinguish PKU and PKS from each other. |

Slight changes to the commit message:

Up until now, pkr_mask had 0 bits for supervisor pages (the U/S bit in
page tables replaces the PFEC.RSVD in page fault error code).
For PKS support, fill in the bits using the same algorithm used for
user mode pages, but with CR4.PKE replaced by CR4.PKS. Because of
this change, CR4.PKS must also be included in the MMU role.

Paolo