lkml.org 
[lkml]   [2020]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 2/3] KVM: x86: Move pkru save/restore to x86.c
From
Date
On 09/05/20 00:09, Jim Mattson wrote:
>> + if (static_cpu_has(X86_FEATURE_PKU) &&
>> + kvm_read_cr4_bits(vcpu, X86_CR4_PKE) &&
>> + vcpu->arch.pkru != vcpu->arch.host_pkru)
>> + __write_pkru(vcpu->arch.pkru);
> This doesn't seem quite right to me. Though rdpkru and wrpkru are
> contingent upon CR4.PKE, the PKRU resource isn't. It can be read with
> XSAVE and written with XRSTOR. So, if we don't set the guest PKRU
> value here, the guest can read the host value, which seems dodgy at
> best.
>
> Perhaps the second conjunct should be: (kvm_read_cr4_bits(vcpu,
> X86_CR4_PKE) || (vcpu->arch.xcr0 & XFEATURE_MASK_PKRU)).

You're right. The bug was preexistent, but we should fix it in 5.7 and
stable as well.

>> }
>> EXPORT_SYMBOL_GPL(kvm_load_guest_xsave_state);
>>
>> void kvm_load_host_xsave_state(struct kvm_vcpu *vcpu)
>> {
>> + /*
>> + * eager fpu is enabled if PKEY is supported and CR4 is switched
>> + * back on host, so it is safe to read guest PKRU from current
>> + * XSAVE.
>> + */
> I don't understand the relevance of this comment to the code below.
>

It's probably stale.

Paolo

\
 
 \ /
  Last update: 2020-05-09 14:59    [W:0.180 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site