]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: x86: Account a variety of miscellaneous allocations
authorSean Christopherson <seanjc@google.com>
Wed, 31 Mar 2021 02:30:25 +0000 (19:30 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Jun 2022 12:13:19 +0000 (14:13 +0200)
commit eba04b20e4861d9bdbd8470a13c0c6e824521a36 upstream.

Switch to GFP_KERNEL_ACCOUNT for a handful of allocations that are
clearly associated with a single task/VM.

Note, there are a several SEV allocations that aren't accounted, but
those can (hopefully) be fixed by using the local stack for memory.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210331023025.2485960-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[sudip: adjust context]
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/sev.c
arch/x86/kvm/vmx/vmx.c

index 23910e6a3f011ccdf30b90954fbf253061cc65ec..e7feaa7910ab3609f3c8f36951ae4c2d641765ca 100644 (file)
@@ -1198,8 +1198,8 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,
                return -EINVAL;
 
        ret  = -ENOMEM;
-       ctl  = kzalloc(sizeof(*ctl),  GFP_KERNEL);
-       save = kzalloc(sizeof(*save), GFP_KERNEL);
+       ctl  = kzalloc(sizeof(*ctl),  GFP_KERNEL_ACCOUNT);
+       save = kzalloc(sizeof(*save), GFP_KERNEL_ACCOUNT);
        if (!ctl || !save)
                goto out_free;
 
index 6c82ef22985d98e8820638c70e396f58345c7a0e..a0c4da5f7d7fe8cf26f74433b17321b65ea4d32b 100644 (file)
@@ -537,7 +537,7 @@ static int sev_launch_measure(struct kvm *kvm, struct kvm_sev_cmd *argp)
                }
 
                ret = -ENOMEM;
-               blob = kmalloc(params.len, GFP_KERNEL);
+               blob = kmalloc(params.len, GFP_KERNEL_ACCOUNT);
                if (!blob)
                        goto e_free;
 
index e729f65c676008e55069fde3fcd4526cfc5b8fe5..cc647dcc228b780e323fb5cebdababb8ff41c1c2 100644 (file)
@@ -619,7 +619,7 @@ static int hv_enable_direct_tlbflush(struct kvm_vcpu *vcpu)
         * evmcs in singe VM shares same assist page.
         */
        if (!*p_hv_pa_pg)
-               *p_hv_pa_pg = kzalloc(PAGE_SIZE, GFP_KERNEL);
+               *p_hv_pa_pg = kzalloc(PAGE_SIZE, GFP_KERNEL_ACCOUNT);
 
        if (!*p_hv_pa_pg)
                return -ENOMEM;