From nobody Mon Feb 9 23:01:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529373136503350.8398668546305; Mon, 18 Jun 2018 18:52:16 -0700 (PDT) Received: from localhost ([::1]:38394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5oR-00069X-JK for importer@patchew.org; Mon, 18 Jun 2018 21:52:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5h5-0000du-K8 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5h4-0007t0-G4 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:27 -0400 Received: from mail-ot0-x241.google.com ([2607:f8b0:4003:c0f::241]:39246) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5h4-0007sn-AQ; Mon, 18 Jun 2018 21:44:26 -0400 Received: by mail-ot0-x241.google.com with SMTP id l15-v6so20759915oth.6; Mon, 18 Jun 2018 18:44:26 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id e5-v6sm7306824otl.2.2018.06.18.18.44.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9u85GqDuv10LNFws7nG2TiUXyiSirr2MAc/8uq/9u2c=; b=Lj9ssl+iuOCXYXWg6pGa0Lwfzlcg42b2ccBXS0mu/3jFf8usXPgW/zsJnopm4TY4UB QieAaywdj9QqMRFPqdCH342Kgmv4LTTbexd/jF1XlsfZpxkc7oBeVbAAZ7eZR75o01or Cv1zm4IyyGfNhh/uCnV/jZsDuzYypIHqZ51VZKd6AOLPaT+4JCKHx/uSzelWr9enJoVa DFhjP29UXENwGOuh5fOhrSFfq7o54E9BQxq1O4/iU9ava/z4wPQ1kTBpSt2cceoOjKiP 773VTiR5CYI4JBABJxGWa1RAirB/eLjkIlypuvLmme3tsD08VTZsiuuAGNHDHj/0CwKv MnRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9u85GqDuv10LNFws7nG2TiUXyiSirr2MAc/8uq/9u2c=; b=lbAMxCm89EiaS28zU5hoqEPQe7aCUYVwJsvPagjehNKudwVC7wYDxS3iUg7houySbi Py8w1+v5LY8kFCrLbfmdyn+DAq4hqBuyCdeRW7iYh/rslCG1PIBr3omttbTmt8QbRirm Cve0dsOk/vNE1N+lwPfsVRdxLK12DdwteXAZUzqeiA/60MtvLYfUmPulmWDN+pXsEwLd EIL1sI6uwkmOlE1ZjyFSp/Y+wK4yZKhB19dnywmLtUJeSoHmjoGjKyOaqbNP2nflf5mf P/7z/7IVpV//6BXENRhKzQkw0p3VDBiYy9eqQxSNXaesblg+AKGZyqmDt7Qb2DCd28Id F2rQ== X-Gm-Message-State: APt69E1/LYitYAnF9z/8etUX71r4c1q0bNpHWsZVyhBbu9yhKEKAItuj mtsJwx+X9++pnCId0EKDHKzgPBfg X-Google-Smtp-Source: ADUXVKL3YlreFg3xdNVJI7MyCgtiQMVyLqIAJ6wbq4cxa87b2v2ZzBykXXf3s0N5B4kkYB85d/+aGw== X-Received: by 2002:a9d:5f09:: with SMTP id f9-v6mr9799064oti.386.1529372665050; Mon, 18 Jun 2018 18:44:25 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:37 -0500 Message-Id: <20180619014319.28272-12-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c0f::241 Subject: [Qemu-devel] [PATCH 011/113] target/ppc: Clarify compat mode max_threads value 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: Greg Kurz , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Gibson We recently had some discussions that were sidetracked for a while, because nearly everyone misapprehended the purpose of the 'max_threads' field in the compatiblity modes table. It's all about guest expectations, not host expectations or support (that's handled elsewhere). In an attempt to avoid a repeat of that confusion, rename the field to 'max_vthreads' and add an explanatory comment. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier Reviewed-by: Greg Kurz Reviewed-by: Jose Ricardo Ziviani (cherry picked from commit abbc124753896f72e3715813ea20dd1924202ff0) Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 4 ++-- target/ppc/compat.c | 25 +++++++++++++++++-------- target/ppc/cpu.h | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f9505d926d..fc6ebe1b3a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -344,7 +344,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineSt= ate *spapr) PowerPCCPU *cpu =3D POWERPC_CPU(cs); DeviceClass *dc =3D DEVICE_GET_CLASS(cs); int index =3D spapr_vcpu_id(cpu); - int compat_smt =3D MIN(smp_threads, ppc_compat_max_threads(cpu)); + int compat_smt =3D MIN(smp_threads, ppc_compat_max_vthreads(cpu)); =20 if (index % spapr->vsmt !=3D 0) { continue; @@ -502,7 +502,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *f= dt, int offset, size_t page_sizes_prop_size; uint32_t vcpus_per_socket =3D smp_threads * smp_cores; uint32_t pft_size_prop[] =3D {0, cpu_to_be32(spapr->htab_shift)}; - int compat_smt =3D MIN(smp_threads, ppc_compat_max_threads(cpu)); + int compat_smt =3D MIN(smp_threads, ppc_compat_max_vthreads(cpu)); sPAPRDRConnector *drc; int drc_index; uint32_t radix_AP_encodings[PPC_PAGE_SIZES_MAX_SZ]; diff --git a/target/ppc/compat.c b/target/ppc/compat.c index 276b5b52c2..807c906f68 100644 --- a/target/ppc/compat.c +++ b/target/ppc/compat.c @@ -32,7 +32,16 @@ typedef struct { uint32_t pvr; uint64_t pcr; uint64_t pcr_level; - int max_threads; + + /* + * Maximum allowed virtual threads per virtual core + * + * This is to stop older guests getting confused by seeing more + * threads than they think the cpu can support. Usually it's + * equal to the number of threads supported on bare metal + * hardware, but not always (see POWER9). + */ + int max_vthreads; } CompatInfo; =20 static const CompatInfo compat_table[] =3D { @@ -45,28 +54,28 @@ static const CompatInfo compat_table[] =3D { .pcr =3D PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05 | PCR_TM_DIS | PCR_VSX_DIS, .pcr_level =3D PCR_COMPAT_2_05, - .max_threads =3D 2, + .max_vthreads =3D 2, }, { /* POWER7, ISA2.06 */ .name =3D "power7", .pvr =3D CPU_POWERPC_LOGICAL_2_06, .pcr =3D PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR= _TM_DIS, .pcr_level =3D PCR_COMPAT_2_06, - .max_threads =3D 4, + .max_vthreads =3D 4, }, { .name =3D "power7+", .pvr =3D CPU_POWERPC_LOGICAL_2_06_PLUS, .pcr =3D PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR= _TM_DIS, .pcr_level =3D PCR_COMPAT_2_06, - .max_threads =3D 4, + .max_vthreads =3D 4, }, { /* POWER8, ISA2.07 */ .name =3D "power8", .pvr =3D CPU_POWERPC_LOGICAL_2_07, .pcr =3D PCR_COMPAT_3_00 | PCR_COMPAT_2_07, .pcr_level =3D PCR_COMPAT_2_07, - .max_threads =3D 8, + .max_vthreads =3D 8, }, { /* POWER9, ISA3.00 */ .name =3D "power9", @@ -80,7 +89,7 @@ static const CompatInfo compat_table[] =3D { * confusing if half of the threads disappear from the guest * if it announces it's POWER9 aware at CAS time. */ - .max_threads =3D 8, + .max_vthreads =3D 8, }, }; =20 @@ -192,14 +201,14 @@ void ppc_set_compat_all(uint32_t compat_pvr, Error **= errp) } } =20 -int ppc_compat_max_threads(PowerPCCPU *cpu) +int ppc_compat_max_vthreads(PowerPCCPU *cpu) { const CompatInfo *compat =3D compat_by_pvr(cpu->compat_pvr); int n_threads =3D CPU(cpu)->nr_threads; =20 if (cpu->compat_pvr) { g_assert(compat); - n_threads =3D MIN(n_threads, compat->max_threads); + n_threads =3D MIN(n_threads, compat->max_vthreads); } =20 return n_threads; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 370b05e76e..1b317845e8 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1382,7 +1382,7 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_= pvr, Error **errp); #if !defined(CONFIG_USER_ONLY) void ppc_set_compat_all(uint32_t compat_pvr, Error **errp); #endif -int ppc_compat_max_threads(PowerPCCPU *cpu); +int ppc_compat_max_vthreads(PowerPCCPU *cpu); void ppc_compat_add_property(Object *obj, const char *name, uint32_t *compat_pvr, const char *basedesc, Error **errp); --=20 2.11.0