Skip to content
  • Paolo Bonzini's avatar
    3ec5ad40
    target/i386: kvm: do not access uninitialized variable on older kernels · 3ec5ad40
    Paolo Bonzini authored
    
    
    KVM support for AMX includes a new system attribute, KVM_X86_XCOMP_GUEST_SUPP.
    Commit 19db68ca ("x86: Grant AMX permission for guest", 2022-03-15) however
    did not fully consider the behavior on older kernels.  First, it warns
    too aggressively.  Second, it invokes the KVM_GET_DEVICE_ATTR ioctl
    unconditionally and then uses the "bitmask" variable, which remains
    uninitialized if the ioctl fails.  Third, kvm_ioctl returns -errno rather
    than -1 on errors.
    
    While at it, explain why the ioctl is needed and KVM_GET_SUPPORTED_CPUID
    is not enough.
    
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    3ec5ad40
    target/i386: kvm: do not access uninitialized variable on older kernels
    Paolo Bonzini authored
    
    
    KVM support for AMX includes a new system attribute, KVM_X86_XCOMP_GUEST_SUPP.
    Commit 19db68ca ("x86: Grant AMX permission for guest", 2022-03-15) however
    did not fully consider the behavior on older kernels.  First, it warns
    too aggressively.  Second, it invokes the KVM_GET_DEVICE_ATTR ioctl
    unconditionally and then uses the "bitmask" variable, which remains
    uninitialized if the ioctl fails.  Third, kvm_ioctl returns -errno rather
    than -1 on errors.
    
    While at it, explain why the ioctl is needed and KVM_GET_SUPPORTED_CPUID
    is not enough.
    
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Loading