From nobody Sun May 12 19:02:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688558899; cv=none; d=zohomail.com; s=zohoarc; b=NskoyzNpqU5ThX+FUxXFq8dQtCsG4c9JZnDT1rQI+KRO3cgvmPprXoB7AyIu35yagA1lK/UJZ1YtH7gz8X3WuE9iePVfFOKYB+oBFjVFd3v9SywUGTHNniynS0QDEsOKu38PbN49/CkOxEZHoNgIWk9egN2IDLBo9Uwbiw5NF6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688558899; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+V5Wb1UvgAvMuIUAuz+YnbQq/PuCuzQgXqqfNnT5OAU=; b=gDtxjLQoV6vSjeZQTGRFwxcFpXM2Xy/OkEMKz43K0MrIgwJ1IWZ44h8a9y0KukyMn7kIOGB8z4DrgUFUinP/HDW5oc8hjl0t2HDhmMZX99WdncCfxFG9xJ7ArR6+GzLiWy8HoWMJQoF+8yRy48r8p+9BONRX5EPog4qGtRLJt24= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688558899853969.6539929512071; Wed, 5 Jul 2023 05:08:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qH1Ha-0004a7-2K; Wed, 05 Jul 2023 08:06:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qH1HY-0004ZP-5Z; Wed, 05 Jul 2023 08:06:52 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qH1HW-0003SD-7K; Wed, 05 Jul 2023 08:06:51 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-666ecf9a081so4977742b3a.2; Wed, 05 Jul 2023 05:06:46 -0700 (PDT) Received: from wheely.local0.net ([61.68.2.145]) by smtp.gmail.com with ESMTPSA id x16-20020a056a00271000b0067459e92801sm15764843pfv.64.2023.07.05.05.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 05:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688558805; x=1691150805; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+V5Wb1UvgAvMuIUAuz+YnbQq/PuCuzQgXqqfNnT5OAU=; b=XD4xPJcMm6gE20E4YNO7EVwOl+b4DfQyLU5VKpEi9vGgIcxYt63fq4SF0FYCXL7aKb 8PWsHNaPrfWL8/yhk1Nw95Q592gnAjqOi+b0utu/nLj8eLC1W0uu1+tnP6RdXBVsxHY0 9Uk1O8EbGaQWqrdKsIut3VNOHr9gQM7gJhLEjaXQ4CB9eiPPphsfUzDZM/fiHWKanUWS Y4aaEVvDHDy/1ftOlyDkrmSts3GKIvYf2WB4hbvSJxUqGomuQjTma4/H/vz8n0gzVUzH 1DSxibcM2O3A902b69ruBBjXR7E49/rpLpjYyomQSaW/qFLrxX0/ojc7ex3KThlmnxYG UF6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688558805; x=1691150805; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+V5Wb1UvgAvMuIUAuz+YnbQq/PuCuzQgXqqfNnT5OAU=; b=Np+f6xY+DjoIciWxHqwbLeonPnhJE5amOK1CryzvZs7ncO7QeifzKeK1Xr/KXCHGvO C+Aa/e4hJQ81fZEbl1Czo7KDuvvI+LVsl0B9ZsE7tQZbtuafgpaTx+DszTxRmsvdJAiR dCfn2SmbRdmavDeZ0S9y/JZU6xec/3k+7YUtmH3+8ADKISZceS1qBXOTC4n5xbXc+H7Y 2FK5RrlWDJhdsCobwWos8re53R9dYmfc+Hb/k8/UzMV9bUCx9hr37C7LtMXDLojformY 6YMhX572wpxEl8pGqhd6dEdPXHlc4UjAwjWaYdTG15Vetay37sCLSy/P0RE+UnU3XX6h FlIg== X-Gm-Message-State: ABy/qLb4LCBlD4Sbc+/5VAsjm5hCMtOFZXhPsQDqhyDg0i+iMOnrGbzA okKtli7dIec9SwXxgP/oINk= X-Google-Smtp-Source: APBJJlGd4zScKooUZf0OEAjx14kIA4z+lZ08NmUoSCiATM2hVhszjBcoEH3Np/yxy+q7NFUuoc6CbA== X-Received: by 2002:a05:6a00:24c9:b0:682:37be:c9fe with SMTP id d9-20020a056a0024c900b0068237bec9femr22204203pfv.10.1688558805258; Wed, 05 Jul 2023 05:06:45 -0700 (PDT) From: Nicholas Piggin To: Daniel Henrique Barboza Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , David Gibson , Greg Kurz , Harsh Prateek Bora , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Joel Stanley Subject: [PATCH v2 1/4] target/ppc: Add LPAR-per-core vs per-thread mode flag Date: Wed, 5 Jul 2023 22:06:28 +1000 Message-Id: <20230705120631.27670-2-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230705120631.27670-1-npiggin@gmail.com> References: <20230705120631.27670-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=npiggin@gmail.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688558900823100002 The Power ISA has the concept of sub-processors: Hardware is allowed to sub-divide a multi-threaded processor into "sub-processors" that appear to privileged programs as multi-threaded processors with fewer threads. POWER9 and POWER10 have two modes, either every thread is a sub-processor or all threads appear as one multi-threaded processor. In the user manuals these are known as "LPAR per thread" / "Thread LPAR", and "LPAR per core" / "1 LPAR", respectively. The practical difference is: in thread LPAR mode, non-hypervisor SPRs are not shared between threads and msgsndp can not be used to message siblings. In 1 LPAR mode, some SPRs are shared and msgsndp is usable. Thrad LPAR allows multiple partitions to run concurrently on the same core, and is a requirement for KVM to run on POWER9/10 (which does not gang-schedule an LPAR on all threads of a core like POWER8 KVM). Traditionally, SMT in PAPR environments including PowerVM and the pseries QEMU machine with KVM acceleration behaves as in 1 LPAR mode. In OPAL systems, Thread LPAR is used. When adding SMT to the powernv machine, it is therefore preferable to emulate Thread LPAR. To account for this difference between pseries and powernv, an LPAR mode flag is added such that SPRs can be implemented as per-LPAR shared, and that becomes either per-thread or per-core depending on the flag. Reviewed-by: Joel Stanley Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- hw/ppc/spapr_cpu_core.c | 2 ++ target/ppc/cpu.h | 3 +++ target/ppc/cpu_init.c | 12 ++++++++++++ target/ppc/excp_helper.c | 4 ++++ target/ppc/misc_helper.c | 8 ++++++++ target/ppc/translate.c | 11 ++++++----- 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index a4e3c2fadd..b482d9754a 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -270,6 +270,8 @@ static bool spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMa= chineState *spapr, env->spr_cb[SPR_PIR].default_value =3D cs->cpu_index; env->spr_cb[SPR_TIR].default_value =3D thread_index; =20 + cpu_ppc_set_1lpar(cpu); + /* Set time-base frequency to 512 MHz. vhyp must be set first. */ cpu_ppc_tb_init(env, SPAPR_TIMEBASE_FREQ); =20 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index af12c93ebc..951f73d89d 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -674,6 +674,8 @@ enum { POWERPC_FLAG_SCV =3D 0x00200000, /* Has >1 thread per core = */ POWERPC_FLAG_SMT =3D 0x00400000, + /* Using "LPAR per core" mode (as opposed to per-thread) = */ + POWERPC_FLAG_SMT_1LPAR=3D 0x00800000, }; =20 /* @@ -1437,6 +1439,7 @@ void store_booke_tsr(CPUPPCState *env, target_ulong v= al); void ppc_tlb_invalidate_all(CPUPPCState *env); void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr); void cpu_ppc_set_vhyp(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp); +void cpu_ppc_set_1lpar(PowerPCCPU *cpu); int ppcmas_tlb_check(CPUPPCState *env, ppcmas_tlb_t *tlb, hwaddr *raddrp, target_ulong address, uint32_t pid); int ppcemb_tlb_search(CPUPPCState *env, target_ulong address, uint32_t pid= ); diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 5f4969664e..905a59aea9 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6629,6 +6629,18 @@ void cpu_ppc_set_vhyp(PowerPCCPU *cpu, PPCVirtualHyp= ervisor *vhyp) env->msr_mask &=3D ~MSR_HVB; } =20 +void cpu_ppc_set_1lpar(PowerPCCPU *cpu) +{ + CPUPPCState *env =3D &cpu->env; + + /* + * pseries SMT means "LPAR per core" mode, e.g., msgsndp is usable + * between threads. + */ + if (env->flags & POWERPC_FLAG_SMT) { + env->flags |=3D POWERPC_FLAG_SMT_1LPAR; + } +} #endif /* !defined(CONFIG_USER_ONLY) */ =20 #endif /* defined(TARGET_PPC64) */ diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 354392668e..7683ea0fc9 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -3130,6 +3130,10 @@ void helper_book3s_msgsndp(CPUPPCState *env, target_= ulong rb) =20 helper_hfscr_facility_check(env, HFSCR_MSGP, "msgsndp", HFSCR_IC_MSGP); =20 + if (!(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + nr_threads =3D 1; /* msgsndp behaves as 1-thread in LPAR-per-threa= d mode*/ + } + if (!dbell_type_server(rb) || ttir >=3D nr_threads) { return; } diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index 1f1af21f33..26e546cc9c 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -191,6 +191,10 @@ target_ulong helper_load_dpdes(CPUPPCState *env) =20 helper_hfscr_facility_check(env, HFSCR_MSGP, "load DPDES", HFSCR_IC_MS= GP); =20 + if (!(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + nr_threads =3D 1; /* DPDES behaves as 1-thread in LPAR-per-thread = mode */ + } + if (nr_threads =3D=3D 1) { if (env->pending_interrupts & PPC_INTERRUPT_DOORBELL) { dpdes =3D 1; @@ -222,6 +226,10 @@ void helper_store_dpdes(CPUPPCState *env, target_ulong= val) =20 helper_hfscr_facility_check(env, HFSCR_MSGP, "store DPDES", HFSCR_IC_M= SGP); =20 + if (!(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + nr_threads =3D 1; /* DPDES behaves as 1-thread in LPAR-per-thread = mode */ + } + if (val & ~(nr_threads - 1)) { qemu_log_mask(LOG_GUEST_ERROR, "Invalid DPDES register value " TARGET_FMT_lx"\n", val); diff --git a/target/ppc/translate.c b/target/ppc/translate.c index db0ba49bdc..4556297ab5 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -246,9 +246,9 @@ static inline bool gen_serialize(DisasContext *ctx) } =20 #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) -static inline bool gen_serialize_core(DisasContext *ctx) +static inline bool gen_serialize_core_lpar(DisasContext *ctx) { - if (ctx->flags & POWERPC_FLAG_SMT) { + if (ctx->flags & POWERPC_FLAG_SMT_1LPAR) { return gen_serialize(ctx); } =20 @@ -451,7 +451,8 @@ static void spr_write_CTRL_ST(DisasContext *ctx, int sp= rn, int gprn) =20 void spr_write_CTRL(DisasContext *ctx, int sprn, int gprn) { - if (!(ctx->flags & POWERPC_FLAG_SMT)) { + if (!(ctx->flags & POWERPC_FLAG_SMT_1LPAR)) { + /* CTRL behaves as 1-thread in LPAR-per-thread mode */ spr_write_CTRL_ST(ctx, sprn, gprn); goto out; } @@ -815,7 +816,7 @@ void spr_write_pcr(DisasContext *ctx, int sprn, int gpr= n) /* DPDES */ void spr_read_dpdes(DisasContext *ctx, int gprn, int sprn) { - if (!gen_serialize_core(ctx)) { + if (!gen_serialize_core_lpar(ctx)) { return; } =20 @@ -824,7 +825,7 @@ void spr_read_dpdes(DisasContext *ctx, int gprn, int sp= rn) =20 void spr_write_dpdes(DisasContext *ctx, int sprn, int gprn) { - if (!gen_serialize_core(ctx)) { + if (!gen_serialize_core_lpar(ctx)) { return; } =20 --=20 2.40.1 From nobody Sun May 12 19:02:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688558917; cv=none; d=zohomail.com; s=zohoarc; b=TvjDyjO6Fe2O0onbQVkSv1zwI0yEKAM6spsQdFkmcs47KCgHc36uqmTcthi5e20zIogW3OUJ8GnZM0c+NMqkl7C5EvO7DdX4j7o0kt5zp4c6QRAGH+FCEGHxh0s9DO83i3sSawvIsYUSvSIjrj4KNssP9qC8t6QyeCCwwaBJYqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688558917; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Yzv+S4Ay2gKi030I04Ege67v32G/RQQBhsK1ryB+b/0=; b=XaWohf/zkOLGQDA+RfTm85vGeWCC4Oa99yoaCLGDV4lk9TiM+yBHuEYES3SEJ3XZQg6bA4OevCAryudCoMzUKddeVFXxD/NI+iOJ0V2Td2asVcVcqKsExhUwSrhzEmc16WGx9GfiXJZGSFwsu9ypO2eyD1fTmb8O1o2lMsJoGj8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688558917384667.867256774472; Wed, 5 Jul 2023 05:08:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qH1Ha-0004aK-MY; Wed, 05 Jul 2023 08:06:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qH1HZ-0004Zb-2D; Wed, 05 Jul 2023 08:06:53 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qH1HX-0003V2-Ct; Wed, 05 Jul 2023 08:06:52 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-55ba5fae2e6so2270478a12.0; Wed, 05 Jul 2023 05:06:50 -0700 (PDT) Received: from wheely.local0.net ([61.68.2.145]) by smtp.gmail.com with ESMTPSA id x16-20020a056a00271000b0067459e92801sm15764843pfv.64.2023.07.05.05.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 05:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688558809; x=1691150809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Yzv+S4Ay2gKi030I04Ege67v32G/RQQBhsK1ryB+b/0=; b=B3K5NCkO2d2FEc1akVi2XSJbdcvttXNKg0eJcfluRxnDPv7PkGcx9LyRm46FZ8D9NG ZWyA8Eop1vtSFevD0TKM7MCkSMMWsI5HeGyIBwiiPk7slrc9A92Lbr3Ij5IdvCN+jkTG dnCkG48KOqCio54wwgzhEzuevNAO8iWfUZCK4/ZX7iTKdVYNGtJdgVwTWeiUAjVmXoJt DvUp9aIoUobUda9wR7eF/zCpNYyX6h26pjNTlxTrefqao7903uiNjsgV7/gyejmfYvQq SmZRi+u/Xg7GIDHZJ7Qj/bSUtrEn7lZG0YvQa+4tKyi9r63Xsbqss4g8UCqaQzA/EdbW KJgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688558809; x=1691150809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yzv+S4Ay2gKi030I04Ege67v32G/RQQBhsK1ryB+b/0=; b=gaiUYz4opVvqs6XbMt/ZYYY4rGDABIkAMwm2MF12vMWSPq5wDxe5uOzuhu9QIRjEH8 0TMZWYlF8Xa16ofyye4lxEn26S9pXu5NuP/LPZaaHkTv8OwPUy3eZxu6krdAjbZEbGh2 9A6XFSFuad4mdY4pDbzJDQ2EhHVuGEdCTTq70X5Ghf6s2gRsV9GnI/xRp25+Kyr/FqMw rXc3Owv4RuUok/ZeK1JqFgv1RtKMsHILhmIl/5d8B55m3+HF67d31sUNgSEre0xcFMp2 MtFutm+R0s48zEJE2m+r6mFrhqcXDGT+SIP44OsTJ+++J83MHhrYXThGvtX1z4sNvt32 63Hw== X-Gm-Message-State: AC+VfDyiASgQycB8IzgSoth8o8yCIhfKq58b+nuNVe0w787AVHSFIAUy SWh1YoBWAG1uEm0dA9X+R9E= X-Google-Smtp-Source: ACHHUZ518X4SG/PV7PtAhIwOlzGK3mwoL0HYw9VsQmkzAMeXGfPtExM2CO1OhFb3uwf7wLPR1HweBw== X-Received: by 2002:a05:6a20:511:b0:12c:8871:26dd with SMTP id 17-20020a056a20051100b0012c887126ddmr17286381pzp.25.1688558809479; Wed, 05 Jul 2023 05:06:49 -0700 (PDT) From: Nicholas Piggin To: Daniel Henrique Barboza Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , David Gibson , Greg Kurz , Harsh Prateek Bora , qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 2/4] target/ppc: SMT support for the HID SPR Date: Wed, 5 Jul 2023 22:06:29 +1000 Message-Id: <20230705120631.27670-3-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230705120631.27670-1-npiggin@gmail.com> References: <20230705120631.27670-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=npiggin@gmail.com; helo=mail-pg1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688558919437100003 HID is a per-core shared register, skiboot sets this (e.g., setting HILE) on one thread and that must affect all threads of the core. Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- target/ppc/cpu_init.c | 2 +- target/ppc/helper.h | 1 + target/ppc/misc_helper.c | 21 +++++++++++++++++++++ target/ppc/spr_common.h | 1 + target/ppc/translate.c | 16 ++++++++++++++++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 905a59aea9..720aad9e05 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -5638,7 +5638,7 @@ static void register_power_common_book4_sprs(CPUPPCSt= ate *env) spr_register_hv(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_core_write_generic, 0x00000000); spr_register_hv(env, SPR_TSCR, "TSCR", SPR_NOACCESS, SPR_NOACCESS, diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 828f7844c8..abec6fe341 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -704,6 +704,7 @@ DEF_HELPER_3(store_dcr, void, env, tl, tl) =20 DEF_HELPER_2(load_dump_spr, void, env, i32) DEF_HELPER_2(store_dump_spr, void, env, i32) +DEF_HELPER_3(spr_core_write_generic, void, env, i32, tl) DEF_HELPER_3(spr_write_CTRL, void, env, i32, tl) =20 DEF_HELPER_4(fscr_facility_check, void, env, i32, i32, i32) diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index 26e546cc9c..692d058665 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -43,6 +43,27 @@ void helper_store_dump_spr(CPUPPCState *env, uint32_t sp= rn) env->spr[sprn]); } =20 +void helper_spr_core_write_generic(CPUPPCState *env, uint32_t sprn, + target_ulong val) +{ + CPUState *cs =3D env_cpu(env); + CPUState *ccs; + uint32_t nr_threads =3D cs->nr_threads; + uint32_t core_id =3D env->spr[SPR_PIR] & ~(nr_threads - 1); + + assert(core_id =3D=3D env->spr[SPR_PIR] - env->spr[SPR_TIR]); + + if (nr_threads =3D=3D 1) { + env->spr[sprn] =3D val; + return; + } + + THREAD_SIBLING_FOREACH(cs, ccs) { + CPUPPCState *cenv =3D &POWERPC_CPU(ccs)->env; + cenv->spr[sprn] =3D val; + } +} + void helper_spr_write_CTRL(CPUPPCState *env, uint32_t sprn, target_ulong val) { diff --git a/target/ppc/spr_common.h b/target/ppc/spr_common.h index fbf52123b5..5995070eaf 100644 --- a/target/ppc/spr_common.h +++ b/target/ppc/spr_common.h @@ -82,6 +82,7 @@ void spr_noaccess(DisasContext *ctx, int gprn, int sprn); void spr_read_generic(DisasContext *ctx, int gprn, int sprn); void spr_write_generic(DisasContext *ctx, int sprn, int gprn); void spr_write_generic32(DisasContext *ctx, int sprn, int gprn); +void spr_core_write_generic(DisasContext *ctx, int sprn, int gprn); void spr_write_MMCR0(DisasContext *ctx, int sprn, int gprn); void spr_write_MMCR1(DisasContext *ctx, int sprn, int gprn); void spr_write_PMC(DisasContext *ctx, int sprn, int gprn); diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 4556297ab5..e6a0709066 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -438,6 +438,22 @@ void spr_write_generic32(DisasContext *ctx, int sprn, = int gprn) #endif } =20 +void spr_core_write_generic(DisasContext *ctx, int sprn, int gprn) +{ + if (!(ctx->flags & POWERPC_FLAG_SMT)) { + spr_write_generic(ctx, sprn, gprn); + return; + } + + if (!gen_serialize(ctx)) { + return; + } + + gen_helper_spr_core_write_generic(cpu_env, tcg_constant_i32(sprn), + cpu_gpr[gprn]); + spr_store_dump_spr(sprn); +} + static void spr_write_CTRL_ST(DisasContext *ctx, int sprn, int gprn) { /* This does not implement >1 thread */ --=20 2.40.1 From nobody Sun May 12 19:02:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688558874; cv=none; d=zohomail.com; s=zohoarc; b=PKnTvOySWz08hreQ9m9zU3BZr51ICWr86gr0yUyUZ61ZtNcsDJhamMGRryFqtJL9gj0Him6uuGMuGfjjEXVC4brHJOXULT/blF4Pe94WXDc5scl9y2Y8Cc3zGm61KGdkPzwJLHBZ5C/wrg+BZmY0LxhVABfhdFccD15wdpHGp2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688558874; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ISNn5BNwQja6M0zx3YuGc7KNUQDOjwu58QCVQx4OvJ8=; b=DqII6Uamc5bWC02jpp4ql9f0ynHBDYbuYAA5Fu4btH9ummjzm5lslwuEM5Y39Cviup28zrC4EKVeOzl5GrCAammE8bAJnuW+xXGfw6bNfhXejaKsHAhLGNQ1n61ion+l1OCBTD5fsffd6oQOgGiBMymXIzXwJEMUjsJYt+eQCks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168855887475476.66745982164423; Wed, 5 Jul 2023 05:07:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qH1Hk-0004fq-Vb; Wed, 05 Jul 2023 08:07:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qH1Hi-0004ei-Uv; Wed, 05 Jul 2023 08:07:02 -0400 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qH1Hd-0003Xy-OH; Wed, 05 Jul 2023 08:06:59 -0400 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-564e4656fecso4320378eaf.0; Wed, 05 Jul 2023 05:06:56 -0700 (PDT) Received: from wheely.local0.net ([61.68.2.145]) by smtp.gmail.com with ESMTPSA id x16-20020a056a00271000b0067459e92801sm15764843pfv.64.2023.07.05.05.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 05:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688558816; x=1691150816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ISNn5BNwQja6M0zx3YuGc7KNUQDOjwu58QCVQx4OvJ8=; b=gJAFnhJC82dtMVsIIbGPMe3afTasssjkpDCIytSZ4uH+kPj/Br01ditDw5ZaKUtvTB pOxSTY+hNV5rhFXj2ZjM0w9wAKY++aWfTBXcyrSaqRDYDpsoFOBbGVnxS9m+WbcE+ytu 1IvZOQuz0ySV3tOZETJ39USEvN/2UcVA3unm7Dvo7jYQNt5oKzTy9HIJ8dPSe7BZub+I O2KUOpJ5qZ8SarU3kcOmi/kLxQkS1CTp11SHA4OEcCiHISlN39VSLa34jgcN4FHctXY7 dR7ZltkJHgSKaN0YRZNnxEXbamBOvQJQdRalcwa0ZneuqYI4EkslORFtjYo0bWtkFzbZ nOlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688558816; x=1691150816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ISNn5BNwQja6M0zx3YuGc7KNUQDOjwu58QCVQx4OvJ8=; b=N4ZGSqHzePlpHhjfIx7Zkke8dacpjjErRa1At/gE+lFSjCuRpTeZc2j9oSljZgPKEw xJsbHMqeia9R3+n3alTebn49cpMD9ERhQtbbEejAjNh4ambEnJBZORSNi2XZ7nlML1YN drEOFpCgZ1COahp3cN+dK9cbtPO8AMrQmqNfDn86C1i/El5O6P5HjUH0cJC2duwCITXp ClPHNsW1YP7qZpiaFGiBcO0H3OCE9a65jaWIkCDbzAhM/fQO0iG2J4BzAesblduR6wD8 NGWQ5kDJ0DORYerCXd87gW+E6mt4Xm1l+IRT2Wt39L5CJACWttm84RW1G0olz0cgKSlp qUfw== X-Gm-Message-State: AC+VfDxQzGYYAq+26Enelj+PgWe+OhJCzvU3FXZ/04YrKZFzUyW9aNXo db11g2a6kjyszfF3jMC5/sE= X-Google-Smtp-Source: ACHHUZ6Hj7pEckqAZGRLFycJa7FTjByUDjxVVVcEvB5Kt5DIKKoKWafnIYRNv0tN4sVf1sH0NoWWTA== X-Received: by 2002:a05:6808:1813:b0:398:268a:1d00 with SMTP id bh19-20020a056808181300b00398268a1d00mr19783942oib.51.1688558813706; Wed, 05 Jul 2023 05:06:53 -0700 (PDT) From: Nicholas Piggin To: Daniel Henrique Barboza Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , David Gibson , Greg Kurz , Harsh Prateek Bora , qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 3/4] ppc/pnv: SMT support for powernv Date: Wed, 5 Jul 2023 22:06:30 +1000 Message-Id: <20230705120631.27670-4-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230705120631.27670-1-npiggin@gmail.com> References: <20230705120631.27670-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c29; envelope-from=npiggin@gmail.com; helo=mail-oo1-xc29.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688558876359100001 Set the TIR default value with the SMT thread index, and place some standard limits on SMT configurations. Now powernv is able to boot skiboot and Linux with a SMT topology, including booting a KVM guest. There are several SPRs and other features (e.g., broadcast msgsnd) that are not implemented, but not used by OPAL or Linux and can be added incrementally. Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- docs/system/ppc/powernv.rst | 5 ----- hw/ppc/pnv.c | 12 ++++++++++++ hw/ppc/pnv_core.c | 13 +++++-------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/system/ppc/powernv.rst b/docs/system/ppc/powernv.rst index c8f9762342..09f3965858 100644 --- a/docs/system/ppc/powernv.rst +++ b/docs/system/ppc/powernv.rst @@ -195,11 +195,6 @@ Use a MTD drive to add a PNOR to the machine, and get = a NVRAM : =20 -drive file=3D./witherspoon.pnor,format=3Draw,if=3Dmtd =20 -CAVEATS -------- - - * No support for multiple HW threads (SMT=3D1). Same as pseries. - Maintainer contact information ------------------------------ =20 diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 5f25fe985a..23740f9d07 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -887,6 +887,18 @@ static void pnv_init(MachineState *machine) =20 pnv->num_chips =3D machine->smp.max_cpus / (machine->smp.cores * machine->smp.threads= ); + + if (machine->smp.threads > 8) { + error_report("Cannot support more than 8 threads/core " + "on a powernv machine"); + exit(1); + } + if (!is_power_of_2(machine->smp.threads)) { + error_report("Cannot support %d threads/core on a powernv" + "machine because it must be a power of 2", + machine->smp.threads); + exit(1); + } /* * TODO: should we decide on how many chips we can create based * on #cores and Venice vs. Murano vs. Naples chip type etc..., diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index ffbc29cbf4..17c267fa61 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -218,12 +218,13 @@ static const MemoryRegionOps pnv_core_power10_xscom_o= ps =3D { .endianness =3D DEVICE_BIG_ENDIAN, }; =20 -static void pnv_core_cpu_realize(PnvCore *pc, PowerPCCPU *cpu, Error **err= p) +static void pnv_core_cpu_realize(PnvCore *pc, PowerPCCPU *cpu, Error **err= p, + int thread_index) { CPUPPCState *env =3D &cpu->env; int core_pir; - int thread_index =3D 0; /* TODO: TCG supports only one thread */ ppc_spr_t *pir =3D &env->spr_cb[SPR_PIR]; + ppc_spr_t *tir =3D &env->spr_cb[SPR_TIR]; Error *local_err =3D NULL; PnvChipClass *pcc =3D PNV_CHIP_GET_CLASS(pc->chip); =20 @@ -239,11 +240,7 @@ static void pnv_core_cpu_realize(PnvCore *pc, PowerPCC= PU *cpu, Error **errp) =20 core_pir =3D object_property_get_uint(OBJECT(pc), "pir", &error_abort); =20 - /* - * The PIR of a thread is the core PIR + the thread index. We will - * need to find a way to get the thread index when TCG supports - * more than 1. We could use the object name ? - */ + tir->default_value =3D thread_index; pir->default_value =3D core_pir + thread_index; =20 /* Set time-base frequency to 512 MHz */ @@ -292,7 +289,7 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) } =20 for (j =3D 0; j < cc->nr_threads; j++) { - pnv_core_cpu_realize(pc, pc->threads[j], &local_err); + pnv_core_cpu_realize(pc, pc->threads[j], &local_err, j); if (local_err) { goto err; } --=20 2.40.1 From nobody Sun May 12 19:02:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688558903; cv=none; d=zohomail.com; s=zohoarc; b=Y89mBHka5N7ivV3Dm61cjuorX9v04PpaemRtHdpBqZV0ORQCBMlDyVLT9jKVuGOgkpRNmfW84Ooo+ztVSNb1IbhD2m0zgWYLJY9yWgutSRBbdgZk1Ax34bykqXW9fyPXhRGTAQKd7YT6sOEX8Q6NAW0Z8TT0187Ztkitc9cIssI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688558903; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+ZObi7tNXlw5mTv75gagExeFYwXpgpLNO47lfD1FSzo=; b=RsqeRA70jvMjZiYKwDvldtJpNs3rP4zaX+I0B2abVkAmQB1sTWnengjKUogtE4z99NsY9l1k4TcjM7dcBpLtFo0WGEIyYy36B5y3cnPdKlGuziNiN9SqIEsUjAPdIsLwFWAYJ1nncu+IWoWBZL8+bhyq9sihGbp4M+OzrDr0uEU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688558903054164.7196138010313; Wed, 5 Jul 2023 05:08:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qH1Hn-0004ip-4B; Wed, 05 Jul 2023 08:07:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qH1Hk-0004fr-Uu; Wed, 05 Jul 2023 08:07:04 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qH1Hj-0003Ye-0k; Wed, 05 Jul 2023 08:07:04 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6686c74183cso4989429b3a.1; Wed, 05 Jul 2023 05:07:00 -0700 (PDT) Received: from wheely.local0.net ([61.68.2.145]) by smtp.gmail.com with ESMTPSA id x16-20020a056a00271000b0067459e92801sm15764843pfv.64.2023.07.05.05.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 05:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688558820; x=1691150820; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+ZObi7tNXlw5mTv75gagExeFYwXpgpLNO47lfD1FSzo=; b=fTN/JdjeEq/qlEXBfdQr2fI4/TfZqJ1VZgESPZLBsJj2B+p36Zqs/YexWB3bF5mupX BZQzaCm7hemvxXFUUZLSauoDN410xTCA7i7ItLrTuoP/MH55l13dgbUhIFZPf4WQEoan 5oM2zd3cpvABxM7ip+pB+jg9+Vz75gF023qzcH+wvKtJd0m8/ZCfXkHEmoJcGzYSUN8C hYkK19VRVrv1QN94Kpt28ohzTivnkcjS2iRTnl+zt3rJSTKlasoJtASt7W11W2ote1mC xQLOrVjcuSKiPffRSzTJy01twY6gK+4rpOOS85iJIfKNYAXs9SyGF9yiGtXwyF25GYIg HgcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688558820; x=1691150820; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+ZObi7tNXlw5mTv75gagExeFYwXpgpLNO47lfD1FSzo=; b=Y7JPFNVWrkv9Sv0g30xXXz/js+s0H3SlhjsQKPCFNZhIcHoM/Kw/yF2BCTQO/Qse8Y lWncHOd0l5lDA6TBzcEcCN05FHle0cWLQAM7uwvHTIMPTs5omRzB+Q17OiQJo47PQyjx k8ixPPS2h0NPaBimzBH7HoekDq1VHiKZzHGPjVPse4N+MXk1BqtlXg9yTVzarzuend6R T42mihQpIyS6D/HV4H73L91kY8CPM0h5lxEgBoftund0G0fRk5w8gYUbJv8k4cXvHZsz 1inNHqVIH5DucOyAg5x2JR9iglwCgLFPLgyxl93j1w1pVOyHXIsK8ZMI0H/6cG3ws9T6 g3aQ== X-Gm-Message-State: ABy/qLYlLvPNoGC8+QFZn/ZT3PU5IgiwP+YxdOX66TWZF8jmovTY5/v9 Dgra9B3QyxiQ91BmRvQt7us= X-Google-Smtp-Source: APBJJlGHfnzIZOlquN/X/Cnb9o8HJ2mGx/7lk3b6CXtnQHKmCRL6QNf0s8Rg04t0Y8LhjOpos+U4/Q== X-Received: by 2002:a05:6a00:1341:b0:674:6dd4:8337 with SMTP id k1-20020a056a00134100b006746dd48337mr23437778pfu.12.1688558819685; Wed, 05 Jul 2023 05:06:59 -0700 (PDT) From: Nicholas Piggin To: Daniel Henrique Barboza Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , David Gibson , Greg Kurz , Harsh Prateek Bora , qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 4/4] tests/avocado: Add powernv machine test script Date: Wed, 5 Jul 2023 22:06:31 +1000 Message-Id: <20230705120631.27670-5-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230705120631.27670-1-npiggin@gmail.com> References: <20230705120631.27670-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=npiggin@gmail.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688558904842100001 This copies ppc_pseries.py to start a set of powernv tests, including a Linux boot test for the newly added SMT mode. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- I didn't add the powernv10 support yet as Cedric suggested, and kept the same vmlinuz because it's common with the pseries tests. We should do that in later tests though. Might be time to update default to power10 soon if the model is becoming more complete... Thanks, Nick tests/avocado/ppc_powernv.py | 87 ++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 tests/avocado/ppc_powernv.py diff --git a/tests/avocado/ppc_powernv.py b/tests/avocado/ppc_powernv.py new file mode 100644 index 0000000000..d0e5c07bde --- /dev/null +++ b/tests/avocado/ppc_powernv.py @@ -0,0 +1,87 @@ +# Test that Linux kernel boots on ppc powernv machines and check the conso= le +# +# Copyright (c) 2018, 2020 Red Hat, Inc. +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +from avocado.utils import archive +from avocado_qemu import QemuSystemTest +from avocado_qemu import wait_for_console_pattern + +class powernvMachine(QemuSystemTest): + + timeout =3D 90 + KERNEL_COMMON_COMMAND_LINE =3D 'printk.time=3D0 ' + panic_message =3D 'Kernel panic - not syncing' + good_message =3D 'VFS: Cannot open root device' + + def do_test_linux_boot(self): + self.require_accelerator("tcg") + kernel_url =3D ('https://archives.fedoraproject.org/pub/archive' + '/fedora-secondary/releases/29/Everything/ppc64le/os' + '/ppc/ppc64/vmlinuz') + kernel_hash =3D '3fe04abfc852b66653b8c3c897a59a689270bc77' + kernel_path =3D self.fetch_asset(kernel_url, asset_hash=3Dkernel_h= ash) + + self.vm.set_console() + kernel_command_line =3D self.KERNEL_COMMON_COMMAND_LINE + 'console= =3Dhvc0' + self.vm.add_args('-kernel', kernel_path, + '-append', kernel_command_line) + self.vm.launch() + + def test_linux_boot(self): + """ + :avocado: tags=3Darch:ppc64 + :avocado: tags=3Dmachine:powernv + :avocado: tags=3Daccel:tcg + """ + + self.do_test_linux_boot() + console_pattern =3D 'VFS: Cannot open root device' + wait_for_console_pattern(self, console_pattern, self.panic_message) + + def test_linux_smp_boot(self): + """ + :avocado: tags=3Darch:ppc64 + :avocado: tags=3Dmachine:powernv + :avocado: tags=3Daccel:tcg + """ + + self.vm.add_args('-smp', '4') + self.do_test_linux_boot() + console_pattern =3D 'smp: Brought up 1 node, 4 CPUs' + wait_for_console_pattern(self, console_pattern, self.panic_message) + wait_for_console_pattern(self, self.good_message, self.panic_messa= ge) + + def test_linux_smt_boot(self): + """ + :avocado: tags=3Darch:ppc64 + :avocado: tags=3Dmachine:powernv + :avocado: tags=3Daccel:tcg + """ + + self.vm.add_args('-smp', '4,threads=3D4') + self.do_test_linux_boot() + console_pattern =3D 'CPU maps initialized for 4 threads per core' + wait_for_console_pattern(self, console_pattern, self.panic_message) + console_pattern =3D 'smp: Brought up 1 node, 4 CPUs' + wait_for_console_pattern(self, console_pattern, self.panic_message) + wait_for_console_pattern(self, self.good_message, self.panic_messa= ge) + + def test_linux_big_boot(self): + """ + :avocado: tags=3Darch:ppc64 + :avocado: tags=3Dmachine:powernv + :avocado: tags=3Daccel:tcg + """ + + self.vm.add_args('-smp', '16,threads=3D4,cores=3D2,sockets=3D2') + + # powernv does not support NUMA + self.do_test_linux_boot() + console_pattern =3D 'CPU maps initialized for 4 threads per core' + wait_for_console_pattern(self, console_pattern, self.panic_message) + console_pattern =3D 'smp: Brought up 2 nodes, 16 CPUs' + wait_for_console_pattern(self, console_pattern, self.panic_message) + wait_for_console_pattern(self, self.good_message, self.panic_messa= ge) --=20 2.40.1