lkml.org 
[lkml]   [2021]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v2 4/6] KVM: x86: Introduce KVM_GET_SREGS2 / KVM_SET_SREGS2
Date
On 26/04/21 13:13, Maxim Levitsky wrote:
> + if (sregs2->flags & KVM_SREGS2_FLAGS_PDPTRS_VALID) {
> +
> + if (!is_pae_paging(vcpu))
> + return -EINVAL;
> +
> + for (i = 0 ; i < 4 ; i++)
> + kvm_pdptr_write(vcpu, i, sregs2->pdptrs[i]);
> +
> + kvm_register_mark_dirty(vcpu, VCPU_EXREG_PDPTR);
> + mmu_reset_needed = 1;
> + }

I think this should also have

else {
if (is_pae_paging(vcpu))
return -EINVAL;
}

but perhaps even better, check it at the beginning:

if ((sregs->cr4 & X86_CR4_PAE) &&
!!(sregs->efer & EFER_LMA) == !!(sregs2->flags & KVM_SREGS2_FLAGS_PDPTRS_VALID))
return -EINVAL;

which technically means the flag is redundant, but there is some value in
having the flag and not allowing the user to shoot itself in the foot.

Paolo

\
 
 \ /
  Last update: 2021-04-26 14:33    [W:0.087 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site