From: David Gibson <david@gibson.dropbear.id.au>
To: Bharata B Rao <bharata@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [FIX PATCH] target/ppc: Proper cleanup when ppc_cpu_realizefn fails
Date: Thu, 15 Jun 2017 15:20:44 +0800 [thread overview]
Message-ID: <20170615072044.GI2614@umbus> (raw)
In-Reply-To: <1497505464-12796-1-git-send-email-bharata@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 2535 bytes --]
On Thu, Jun 15, 2017 at 11:14:24AM +0530, Bharata B Rao wrote:
> If ppc_cpu_realizefn() fails after cpu_exec_realizefn() has been
> called, we will have to undo whatever cpu_exec_realizefn() did
> by explicitly calling cpu_exec_unrealizeffn() which is currently
> missing. Failure to do this proper cleanup will result in CPU
> which was never fully realized to linger on the cpus list causing
> SIGSEGV later (for eg when running "info cpus").
>
> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Applied to ppc-for-2.10.
> ---
> target/ppc/translate_init.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c
> index e837cd2..53aff5a 100644
> --- a/target/ppc/translate_init.c
> +++ b/target/ppc/translate_init.c
> @@ -9825,14 +9825,14 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)
> error_append_hint(errp, "Adjust the number of cpus to %d "
> "or try to raise the number of threads per core\n",
> cpu->cpu_dt_id * smp_threads / max_smt);
> - return;
> + goto unrealize;
> }
> #endif
>
> if (tcg_enabled()) {
> if (ppc_fixup_cpu(cpu) != 0) {
> error_setg(errp, "Unable to emulate selected CPU with TCG");
> - return;
> + goto unrealize;
> }
> }
>
> @@ -9841,14 +9841,14 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)
> error_setg(errp, "CPU does not possess a BookE or 4xx MMU. "
> "Please use qemu-system-ppc or qemu-system-ppc64 instead "
> "or choose another CPU model.");
> - return;
> + goto unrealize;
> }
> #endif
>
> create_ppc_opcodes(cpu, &local_err);
> if (local_err != NULL) {
> error_propagate(errp, local_err);
> - return;
> + goto unrealize;
> }
> init_ppc_proc(cpu);
>
> @@ -10033,6 +10033,10 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)
> fflush(stdout);
> }
> #endif
> + return;
> +
> +unrealize:
> + cpu_exec_unrealizefn(cs);
> }
>
> static void ppc_cpu_unrealizefn(DeviceState *dev, Error **errp)
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
prev parent reply other threads:[~2017-06-15 7:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-15 5:44 [Qemu-devel] [FIX PATCH] target/ppc: Proper cleanup when ppc_cpu_realizefn fails Bharata B Rao
2017-06-15 6:10 ` no-reply
2017-06-15 7:20 ` David Gibson [this message]
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=20170615072044.GI2614@umbus \
--to=david@gibson.dropbear.id.au \
--cc=bharata@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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).