* [Qemu-devel] [PATCH] monitor: fix crash for platforms without a CPU 0
@ 2016-09-21 5:29 David Gibson
2016-09-21 11:36 ` Igor Mammedov
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: David Gibson @ 2016-09-21 5:29 UTC (permalink / raw)
To: qemu-trivial
Cc: qemu-ppc, qemu-devel, ehabkost, lcapitulino, armbru, imammedo,
David Gibson, Cédric Le Goater
Now that we allow CPU hot unplug on a few platforms, we can end up in a
situation where we don't have a CPU with index 0. Or at least we could,
if we didn't have code to explicitly prohibit unplug of CPU 0.
Longer term we want to allow CPU 0 unplug, this patch is an early step in
allowing this, by removing an assumption in the monitor code that CPU 0
always exists.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[dwg: Rewrote commit message to better explain background]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
monitor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Anyone want to volunteer to take this through their tree? If not, I
can take it through my ppc tree.
diff --git a/monitor.c b/monitor.c
index 8bb8bbf..83c4edf 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1025,7 +1025,7 @@ int monitor_set_cpu(int cpu_index)
CPUState *mon_get_cpu(void)
{
if (!cur_mon->mon_cpu) {
- monitor_set_cpu(0);
+ monitor_set_cpu(first_cpu->cpu_index);
}
cpu_synchronize_state(cur_mon->mon_cpu);
return cur_mon->mon_cpu;
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] monitor: fix crash for platforms without a CPU 0
2016-09-21 5:29 [Qemu-devel] [PATCH] monitor: fix crash for platforms without a CPU 0 David Gibson
@ 2016-09-21 11:36 ` Igor Mammedov
2016-09-21 12:14 ` Eduardo Habkost
2016-09-21 14:50 ` Luiz Capitulino
2 siblings, 0 replies; 6+ messages in thread
From: Igor Mammedov @ 2016-09-21 11:36 UTC (permalink / raw)
To: David Gibson
Cc: qemu-trivial, ehabkost, qemu-devel, armbru, lcapitulino,
qemu-ppc, Cédric Le Goater
On Wed, 21 Sep 2016 15:29:26 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:
> Now that we allow CPU hot unplug on a few platforms, we can end up in a
> situation where we don't have a CPU with index 0. Or at least we could,
> if we didn't have code to explicitly prohibit unplug of CPU 0.
>
> Longer term we want to allow CPU 0 unplug, this patch is an early step in
> allowing this, by removing an assumption in the monitor code that CPU 0
> always exists.
>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> [dwg: Rewrote commit message to better explain background]
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> ---
> monitor.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Anyone want to volunteer to take this through their tree? If not, I
> can take it through my ppc tree.
>
> diff --git a/monitor.c b/monitor.c
> index 8bb8bbf..83c4edf 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1025,7 +1025,7 @@ int monitor_set_cpu(int cpu_index)
> CPUState *mon_get_cpu(void)
> {
> if (!cur_mon->mon_cpu) {
> - monitor_set_cpu(0);
> + monitor_set_cpu(first_cpu->cpu_index);
> }
> cpu_synchronize_state(cur_mon->mon_cpu);
> return cur_mon->mon_cpu;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] monitor: fix crash for platforms without a CPU 0
2016-09-21 5:29 [Qemu-devel] [PATCH] monitor: fix crash for platforms without a CPU 0 David Gibson
2016-09-21 11:36 ` Igor Mammedov
@ 2016-09-21 12:14 ` Eduardo Habkost
2016-09-22 0:17 ` David Gibson
2016-09-21 14:50 ` Luiz Capitulino
2 siblings, 1 reply; 6+ messages in thread
From: Eduardo Habkost @ 2016-09-21 12:14 UTC (permalink / raw)
To: David Gibson
Cc: qemu-trivial, qemu-ppc, qemu-devel, lcapitulino, armbru,
imammedo, Cédric Le Goater
On Wed, Sep 21, 2016 at 03:29:26PM +1000, David Gibson wrote:
> Now that we allow CPU hot unplug on a few platforms, we can end up in a
> situation where we don't have a CPU with index 0. Or at least we could,
> if we didn't have code to explicitly prohibit unplug of CPU 0.
>
> Longer term we want to allow CPU 0 unplug, this patch is an early step in
> allowing this, by removing an assumption in the monitor code that CPU 0
> always exists.
>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> [dwg: Rewrote commit message to better explain background]
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> monitor.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Anyone want to volunteer to take this through their tree? If not, I
> can take it through my ppc tree.
>
> diff --git a/monitor.c b/monitor.c
> index 8bb8bbf..83c4edf 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1025,7 +1025,7 @@ int monitor_set_cpu(int cpu_index)
> CPUState *mon_get_cpu(void)
> {
> if (!cur_mon->mon_cpu) {
> - monitor_set_cpu(0);
> + monitor_set_cpu(first_cpu->cpu_index);
So, we are replacing the "CPU 0 always exists" assumption with a
"first_cpu is always non-NULL" assumption.
But considering that the first_cpu assumption already exists
elsewhere and those cases can be found easily using grep, I think
this is OK. So:
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
BTW, it is also possible to crash QEMU by unplugging the current
monitor CPU;
(qemu) device_add qemu64-x86_64-cpu,socket-id=2,core-id=0,thread-id=0,id=mycpu
(qemu) cpu 2
(qemu) device_del mycpu
(qemu) info registers
qemu:qemu_cpu_kick_thread: No such process
$
--
Eduardo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] monitor: fix crash for platforms without a CPU 0
2016-09-21 5:29 [Qemu-devel] [PATCH] monitor: fix crash for platforms without a CPU 0 David Gibson
2016-09-21 11:36 ` Igor Mammedov
2016-09-21 12:14 ` Eduardo Habkost
@ 2016-09-21 14:50 ` Luiz Capitulino
2016-09-22 0:17 ` David Gibson
2 siblings, 1 reply; 6+ messages in thread
From: Luiz Capitulino @ 2016-09-21 14:50 UTC (permalink / raw)
To: David Gibson
Cc: qemu-trivial, qemu-ppc, qemu-devel, ehabkost, armbru, imammedo,
Cédric Le Goater
On Wed, 21 Sep 2016 15:29:26 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:
> Now that we allow CPU hot unplug on a few platforms, we can end up in a
> situation where we don't have a CPU with index 0. Or at least we could,
> if we didn't have code to explicitly prohibit unplug of CPU 0.
>
> Longer term we want to allow CPU 0 unplug, this patch is an early step in
> allowing this, by removing an assumption in the monitor code that CPU 0
> always exists.
>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> [dwg: Rewrote commit message to better explain background]
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> monitor.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Anyone want to volunteer to take this through their tree? If not, I
> can take it through my ppc tree.
Please do.
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
>
> diff --git a/monitor.c b/monitor.c
> index 8bb8bbf..83c4edf 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1025,7 +1025,7 @@ int monitor_set_cpu(int cpu_index)
> CPUState *mon_get_cpu(void)
> {
> if (!cur_mon->mon_cpu) {
> - monitor_set_cpu(0);
> + monitor_set_cpu(first_cpu->cpu_index);
> }
> cpu_synchronize_state(cur_mon->mon_cpu);
> return cur_mon->mon_cpu;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] monitor: fix crash for platforms without a CPU 0
2016-09-21 12:14 ` Eduardo Habkost
@ 2016-09-22 0:17 ` David Gibson
0 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2016-09-22 0:17 UTC (permalink / raw)
To: Eduardo Habkost
Cc: qemu-trivial, qemu-ppc, qemu-devel, lcapitulino, armbru,
imammedo, Cédric Le Goater
[-- Attachment #1: Type: text/plain, Size: 2273 bytes --]
On Wed, Sep 21, 2016 at 09:14:02AM -0300, Eduardo Habkost wrote:
> On Wed, Sep 21, 2016 at 03:29:26PM +1000, David Gibson wrote:
> > Now that we allow CPU hot unplug on a few platforms, we can end up in a
> > situation where we don't have a CPU with index 0. Or at least we could,
> > if we didn't have code to explicitly prohibit unplug of CPU 0.
> >
> > Longer term we want to allow CPU 0 unplug, this patch is an early step in
> > allowing this, by removing an assumption in the monitor code that CPU 0
> > always exists.
> >
> > Signed-off-by: Cédric Le Goater <clg@kaod.org>
> > [dwg: Rewrote commit message to better explain background]
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> > monitor.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > Anyone want to volunteer to take this through their tree? If not, I
> > can take it through my ppc tree.
> >
> > diff --git a/monitor.c b/monitor.c
> > index 8bb8bbf..83c4edf 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -1025,7 +1025,7 @@ int monitor_set_cpu(int cpu_index)
> > CPUState *mon_get_cpu(void)
> > {
> > if (!cur_mon->mon_cpu) {
> > - monitor_set_cpu(0);
> > + monitor_set_cpu(first_cpu->cpu_index);
>
> So, we are replacing the "CPU 0 always exists" assumption with a
> "first_cpu is always non-NULL" assumption.
Well, we're replacing "CPU 0 is always present" assumption with "At
least one CPU is always present", which is a strictly weaker
constraint.
> But considering that the first_cpu assumption already exists
> elsewhere and those cases can be found easily using grep, I think
> this is OK. So:
>
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
>
> BTW, it is also possible to crash QEMU by unplugging the current
> monitor CPU;
Ah... good point.
> (qemu) device_add qemu64-x86_64-cpu,socket-id=2,core-id=0,thread-id=0,id=mycpu
> (qemu) cpu 2
> (qemu) device_del mycpu
> (qemu) info registers
> qemu:qemu_cpu_kick_thread: No such process
> $
>
--
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 --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] monitor: fix crash for platforms without a CPU 0
2016-09-21 14:50 ` Luiz Capitulino
@ 2016-09-22 0:17 ` David Gibson
0 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2016-09-22 0:17 UTC (permalink / raw)
To: Luiz Capitulino
Cc: qemu-trivial, qemu-ppc, qemu-devel, ehabkost, armbru, imammedo,
Cédric Le Goater
[-- Attachment #1: Type: text/plain, Size: 1715 bytes --]
On Wed, Sep 21, 2016 at 10:50:49AM -0400, Luiz Capitulino wrote:
> On Wed, 21 Sep 2016 15:29:26 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > Now that we allow CPU hot unplug on a few platforms, we can end up in a
> > situation where we don't have a CPU with index 0. Or at least we could,
> > if we didn't have code to explicitly prohibit unplug of CPU 0.
> >
> > Longer term we want to allow CPU 0 unplug, this patch is an early step in
> > allowing this, by removing an assumption in the monitor code that CPU 0
> > always exists.
> >
> > Signed-off-by: Cédric Le Goater <clg@kaod.org>
> > [dwg: Rewrote commit message to better explain background]
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> > monitor.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > Anyone want to volunteer to take this through their tree? If not, I
> > can take it through my ppc tree.
>
> Please do.
Ok, merged to ppc-for-2.8.
>
> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
>
> >
> > diff --git a/monitor.c b/monitor.c
> > index 8bb8bbf..83c4edf 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -1025,7 +1025,7 @@ int monitor_set_cpu(int cpu_index)
> > CPUState *mon_get_cpu(void)
> > {
> > if (!cur_mon->mon_cpu) {
> > - monitor_set_cpu(0);
> > + monitor_set_cpu(first_cpu->cpu_index);
> > }
> > cpu_synchronize_state(cur_mon->mon_cpu);
> > return cur_mon->mon_cpu;
>
--
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 --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-09-22 0:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21 5:29 [Qemu-devel] [PATCH] monitor: fix crash for platforms without a CPU 0 David Gibson
2016-09-21 11:36 ` Igor Mammedov
2016-09-21 12:14 ` Eduardo Habkost
2016-09-22 0:17 ` David Gibson
2016-09-21 14:50 ` Luiz Capitulino
2016-09-22 0:17 ` David Gibson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.