qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
	Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
	Richard Henderson <richard.henderson@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Laurent Vivier <laurent@vivier.eu>,
	Aleksandar Markovic <amarkovic@wavecomp.com>,
	Michael Walle <michael@walle.cc>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>,
	Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [PATCH 2/2] cpu: Assert a vCPU is created before resetting it
Date: Mon, 9 Mar 2020 13:10:06 +0000	[thread overview]
Message-ID: <CAFEAcA9LcTUmBuzsHmOSPKOfiyfPy0+gPhKpQdd91EV76HapxA@mail.gmail.com> (raw)
In-Reply-To: <20200309121103.20234-3-philmd@redhat.com>

On Mon, 9 Mar 2020 at 12:11, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> cpu_reset() might modify architecture-specific fields allocated
> by qemu_init_vcpu(). To avoid bugs similar to the one fixed in
> commit 00d0f7cb66 when introducing new architectures, assert a
> vCPU is created before resetting it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/core/cpu.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/core/cpu.c b/hw/core/cpu.c
> index fe65ca62ac..09e49f8d6a 100644
> --- a/hw/core/cpu.c
> +++ b/hw/core/cpu.c
> @@ -251,6 +251,7 @@ void cpu_reset(CPUState *cpu)
>  {
>      CPUClass *klass = CPU_GET_CLASS(cpu);
>
> +    assert(cpu->created);
>      if (klass->reset != NULL) {
>          (*klass->reset)(cpu);
>      }

This will conflict with the change to use DeviceClass::reset.

Ideally we should do an equivalent assert in the DeviceClass
(and flush out all the bugs where we forgot to realize the
device before using it).

thanks
-- PMM


  reply	other threads:[~2020-03-09 13:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09 12:11 [PATCH 0/2] cpu: Avoid latent bug calling cpu_reset() on uninitialized vCPU Philippe Mathieu-Daudé
2020-03-09 12:11 ` [PATCH 1/2] cpu: Do not reset a vCPU before it is created Philippe Mathieu-Daudé
2020-03-09 13:08   ` Laurent Vivier
2020-03-09 13:09   ` Peter Maydell
2020-03-09 13:13     ` Laurent Vivier
2020-03-09 13:18       ` Peter Maydell
2020-03-09 13:28         ` Laurent Vivier
2020-03-09 12:11 ` [PATCH 2/2] cpu: Assert a vCPU is created before resetting it Philippe Mathieu-Daudé
2020-03-09 13:10   ` Peter Maydell [this message]
2020-03-09 15:30     ` 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=CAFEAcA9LcTUmBuzsHmOSPKOfiyfPy0+gPhKpQdd91EV76HapxA@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=aleksandar.rikalo@rt-rk.com \
    --cc=amarkovic@wavecomp.com \
    --cc=aurelien@aurel32.net \
    --cc=edgar.iglesias@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=kbastian@mail.uni-paderborn.de \
    --cc=laurent@vivier.eu \
    --cc=michael@walle.cc \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).