qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Harsh Prateek Bora <harshpb@linux.ibm.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	qemu-ppc@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Chinmay Rath" <rathc@linux.ibm.com>,
	kvm@vger.kernel.org, "Glenn Miles" <milesg@linux.ibm.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: Re: [PATCH v2 1/3] target/ppc/kvm: Avoid using alloca()
Date: Tue, 2 Sep 2025 12:11:18 +0530	[thread overview]
Message-ID: <a359291c-e174-42db-a917-6a6146d280c0@linux.ibm.com> (raw)
In-Reply-To: <20250901132626.28639-2-philmd@linaro.org>



On 9/1/25 18:56, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   target/ppc/kvm.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index d145774b09a..937b9ee986d 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -2760,11 +2760,10 @@ 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;
> +    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;

Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>


  parent reply	other threads:[~2025-09-02  6:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-01 13:26 [PATCH v2 0/3] system: Forbid alloca() Philippe Mathieu-Daudé
2025-09-01 13:26 ` [PATCH v2 1/3] target/ppc/kvm: Avoid using alloca() Philippe Mathieu-Daudé
2025-09-01 13:30   ` Peter Maydell
2025-09-01 14:07   ` Manos Pitsidianakis
2025-09-02  6:41   ` Harsh Prateek Bora [this message]
2025-09-02 14:05   ` Stefan Hajnoczi
2025-09-01 13:26 ` [PATCH v2 2/3] buildsys: Prohibit alloca() use on system code Philippe Mathieu-Daudé
2025-09-01 13:37   ` Daniel P. Berrangé
2025-09-01 13:26 ` [PATCH v2 3/3] docs/devel/style: Mention alloca() family API is forbidden Philippe Mathieu-Daudé
2025-09-01 14:05   ` Manos Pitsidianakis
2025-09-01 14:41     ` Philippe Mathieu-Daudé
2025-09-02 14:04   ` Stefan Hajnoczi
2025-09-02 10:17 ` [PATCH v2 0/3] system: Forbid alloca() Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a359291c-e174-42db-a917-6a6146d280c0@linux.ibm.com \
    --to=harshpb@linux.ibm.com \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=milesg@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rathc@linux.ibm.com \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).