qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] cpu: don't allow negative core id
@ 2017-08-02 10:32 Laurent Vivier
  2017-08-02 13:42 ` Philippe Mathieu-Daudé
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Laurent Vivier @ 2017-08-02 10:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Gibson, Eduardo Habkost, qemu-ppc, Thomas Huth,
	Paolo Bonzini, Laurent Vivier

With pseries machine type a negative core-id is not managed properly:
-1 gives an inaccurate error message ("core -1 already populated"),
-2 crashes QEMU (core dump)

As it seems a negative value is invalid for any architecture,
instead of checking this in spapr_core_pre_plug() I think it's better
to check this in the generic part, core_prop_set_core_id()

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/cpu/core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/cpu/core.c b/hw/cpu/core.c
index 2bf960d..bd578ab 100644
--- a/hw/cpu/core.c
+++ b/hw/cpu/core.c
@@ -33,6 +33,11 @@ static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name,
         return;
     }
 
+    if (value < 0) {
+        error_setg(errp, "Invalid core id %"PRId64, value);
+        return;
+    }
+
     core->core_id = value;
 }
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-08-03 15:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-02 10:32 [Qemu-devel] [PATCH] cpu: don't allow negative core id Laurent Vivier
2017-08-02 13:42 ` Philippe Mathieu-Daudé
2017-08-02 13:50   ` Laurent Vivier
2017-08-02 21:29     ` Eduardo Habkost
2017-08-03 13:21       ` Philippe Mathieu-Daudé
2017-08-03 15:04       ` Igor Mammedov
2017-08-02 13:58 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2017-08-02 14:22 ` [Qemu-devel] " David Gibson

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).