From patchwork Fri Mar 31 04:51:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 745491 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vvTcx5Q92z9s2x for ; Fri, 31 Mar 2017 15:52:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="n4l7sc/v"; dkim-atps=neutral Received: from localhost ([::1]:38856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctoXn-000698-8N for incoming@patchwork.ozlabs.org; Fri, 31 Mar 2017 00:52:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctoXT-00068c-6N for qemu-devel@nongnu.org; Fri, 31 Mar 2017 00:51:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctoXQ-0000YC-5I for qemu-devel@nongnu.org; Fri, 31 Mar 2017 00:51:55 -0400 Received: from ozlabs.org ([103.22.144.67]:58191) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctoXP-0000WR-Oq; Fri, 31 Mar 2017 00:51:52 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3vvTcN3fvcz9s2x; Fri, 31 Mar 2017 15:51:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1490935908; bh=oB0+DmzgzQYYofwi8/sTGPfsMJ35bCASgck7KrM9qFY=; h=From:To:Cc:Subject:Date:From; b=n4l7sc/v1yUVIyNLnKxik3rAA6uYOQGMfYLixVSEVwQwUR7gaRgl01HVrDc0vH7Pg qVSM7W0HGaurab/aO8ITV7yTZlTBnTZ9rk1NnmP3h6cV7rF7USCcTVSUXGY+MX3AEV nBF39sSPijStsxgo0XDDIXERlwUZPTqaFboOWV90= From: David Gibson To: thuth@redhat.com, imammedo@redhat.com Date: Fri, 31 Mar 2017 15:51:44 +1100 Message-Id: <20170331045144.9307-1-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PATCH for-2.9] pseries: Enforce homogeneous threads-per-core X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, ehabkost@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" For reasons that may be useful in future, CPU core objects, as used on the pseries machine type have their own nr-threads property, potentially allowing cores with different numbers of threads in the same system. If the user/management uses the values specified in query-hotpluggable-cpus as they're expected to do, this will never matter in pratice. But that's not actually enforced - it's possible to manually specify a core with a different number of threads from that in -smp. That will confuse the platform - most immediately, this can be used to create a CPU thread with index above max_cpus which leads to an assertion failure in spapr_cpu_core_realize(). For now, enforce that all cores must have the same, standard, number of threads. While we're at it, also enforce that the core ids are correctly aligned based on that number of threads. Signed-off-by: David Gibson --- hw/ppc/spapr_cpu_core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 6883f09..935ee62 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -167,6 +167,18 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) void *obj; int i, j; + if (cc->nr_threads != smp_threads) { + error_setg(errp, + "Invalid nr-threads=%d of CPU[core-id: %d], must be %d", + cc->nr_threads, cc->core_id, smp_threads); + return; + } + if ((cc->core_id % smp_threads) != 0) { + error_setg(errp, "Invalid CPU core-id=%d, must be a multiple of %d", + cc->core_id, smp_threads); + return; + } + sc->threads = g_malloc0(size * cc->nr_threads); for (i = 0; i < cc->nr_threads; i++) { int node_id;