From 32fb43910b25c19261f4c3153a7442713cbc4de3 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Fri, 4 Aug 2017 16:50:30 +0200 Subject: [PATCH 2/4] cpu: don't allow negative core id RH-Author: Laurent Vivier Message-id: <20170804165030.26586-1-lvivier@redhat.com> Patchwork-id: 75897 O-Subject: [RHEL-ALT-7.4 qemu-kvm PATCH] cpu: don't allow negative core id Bugzilla: 1476181 RH-Acked-by: David Gibson RH-Acked-by: Thomas Huth RH-Acked-by: Eduardo Habkost 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 Message-Id: <20170802103259.25940-1-lvivier@redhat.com> Reviewed-by: Greg Kurz Reviewed-by: David Gibson Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost (cherry picked from commit be2960baae07e5257cde8c814cbd91647e235147) Signed-off-by: Laurent Vivier Signed-off-by: Miroslav Rezanina --- 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; } -- 1.8.3.1