• Alexey Kardashevskiy's avatar
    KVM: PPC: Account TCE-containing pages in locked_vm · f8626985
    Alexey Kardashevskiy authored
    At the moment pages used for TCE tables (in addition to pages addressed
    by TCEs) are not counted in locked_vm counter so a malicious userspace
    tool can call ioctl(KVM_CREATE_SPAPR_TCE) as many times as
    RLIMIT_NOFILE and lock a lot of memory.
    
    This adds counting for pages used for TCE tables.
    
    This counts the number of pages required for a table plus pages for
    the kvmppc_spapr_tce_table struct (TCE table descriptor) itself.
    
    This changes release_spapr_tce_table() to store @npages on stack to
    avoid calling kvmppc_stt_npages() in the loop (tiny optimization,
    probably).
    
    This does not change the amount of used memory.
    Signed-off-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
    Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
    Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
    f8626985
book3s_64_vio.c 5.03 KB