diff options
author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-06-10 11:19:34 +0200 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-09-02 17:56:57 +0200 |
commit | b8d6e05f16b77231d11b96659072b302290b3396 (patch) | |
tree | e45901dc66f3a742246a9de8063315b3ddf631b5 | |
parent | a80151c9da1a848e5d3ad7153080beaf0745e4cc (diff) | |
download | qemu-b8d6e05f16b77231d11b96659072b302290b3396.zip qemu-b8d6e05f16b77231d11b96659072b302290b3396.tar.gz qemu-b8d6e05f16b77231d11b96659072b302290b3396.tar.bz2 |
target/ppc/kvm: Avoid using alloca()
kvmppc_load_htab_chunk() is used for migration, thus is not
a hot path. Use the heap instead of the stack, removing the
alloca() call.
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20250901132626.28639-2-philmd@linaro.org>
-rw-r--r-- | target/ppc/kvm.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index d145774..2521ff6 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2760,11 +2760,11 @@ int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns) int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, uint16_t n_valid, uint16_t n_invalid, Error **errp) { - struct kvm_get_htab_header *buf; - size_t chunksize = sizeof(*buf) + n_valid * HASH_PTE_SIZE_64; + size_t chunksize = sizeof(struct kvm_get_htab_header) + + n_valid * HASH_PTE_SIZE_64; + g_autofree struct kvm_get_htab_header *buf = g_malloc(chunksize); ssize_t rc; - buf = alloca(chunksize); buf->index = index; buf->n_valid = n_valid; buf->n_invalid = n_invalid; |