On 27/01/21 04:00, Chenyi Qiang wrote:
if (pte_access & PT_USER_MASK)
pkr_bits = (vcpu->arch.pkru >> (pte_pkey * 2)) & 3;
+ else if (!kvm_get_msr(vcpu, MSR_IA32_PKRS, &pkrs))
+ pkr_bits = (pkrs >> (pte_pkey * 2)) & 3;
You should be able to always use vcpu->arch.pkrs here. So
pkr = pte_access & PT_USER_MASK ? vcpu->arch.pkru : vcpu->arch.pkrs;
pkr_bits = (pkr >> pte_pkey * 2) & 3;
Concerning vcpu->arch.pkrs would be the only use case in current
submitted patches, is it still necessary to shadow it?
Yes, please do. kvm_get_msr is pretty slow, and the code becomes
simpler too.
Paolo