]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
KVM: PPC: Account TCE-containing pages in locked_vm
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Mon, 15 Feb 2016 01:55:06 +0000 (12:55 +1100)
committerPaul Mackerras <paulus@samba.org>
Tue, 16 Feb 2016 02:44:26 +0000 (13:44 +1100)
commitf8626985c7c2485c423ce9f448028f81535b0ecc
treef6f7a2b997299bf4dcaa0571a754080795f77960
parent366baf28ee3fc22dea504a0bddf8edd1e9bcee70
KVM: PPC: Account TCE-containing pages in locked_vm

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: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/kvm/book3s_64_vio.c