From nobody Wed May 15 16:02:53 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=1688379485; cv=none; d=zohomail.com; s=zohoarc; b=TMTut4SKFNROZfcETdQySyqfZMjx7+lkYCiJA31Prwr/3O8iC1DTnyM7BHVRsWcyg5XnxvcEbCMe854TYkvhhqxuKhpWCfnT05WHySZq3CSyllcrr9Tn10fEtySTuNF1zD9oBjgG/401iGQrWvuWeww4sWdSCMOBOM1DPO9PsfI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379485; 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=2qF/Z9+zgr+HRi5gA8P3eTX+di+A7NJtnLcplKmqPHM=; b=A+o78az/WBBND0JU0Glnpy2frHdicuPyS3VKborQZhRtoIgklE+zrNxOrE6/55LGbiE92YKNgE3nNJxp8dVGGxuKxz2bziA1Ih5aqwfwbZX9vyqc2qDoHCz3vr6oz6Sgmk+pDVBRt+yggyrAFHn9cGjxwfzpQu5QdqjR+iKmkz0= 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 1688379485778741.1022423472898; Mon, 3 Jul 2023 03:18:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGcv-0000jN-6A; Mon, 03 Jul 2023 06:17:49 -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 1qGGcU-0000KG-4q; Mon, 03 Jul 2023 06:17:25 -0400 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGcS-0000vR-1U; Mon, 03 Jul 2023 06:17:21 -0400 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6b71cdb47e1so3527125a34.2; Mon, 03 Jul 2023 03:17:19 -0700 (PDT) Received: from wheely.local0.net ([118.210.96.60]) by smtp.gmail.com with ESMTPSA id o2-20020aa79782000000b006826c9e4397sm3887727pfp.48.2023.07.03.03.17.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688379438; x=1690971438; 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=2qF/Z9+zgr+HRi5gA8P3eTX+di+A7NJtnLcplKmqPHM=; b=Y+3VxzgBEnwDPn193SKgyMkAz+G0gLGz3JFLCp9EWvAjZ1u98h51qF0zl3ZUu8hAl1 IlrWzYZEZJmBo09y8E6wht/AUSquvDZuvdVHZOPnKsA2VWOMRHcwS0XNfLe3zZT1YmOF fnEnGi4w3q6P52WUPLEHFThGf5pxrLIvU8HiPKmr0aOZiRnyUZ1uISfkWRPDBzeMOktu SyxXTWzGbb1FU14JfBLv109hGguUOPP5iRsSEWB+ei971y+WKsD3ZqTTRDauKC+3UTBq 9TXac+VwXWdHWd/hJd9aIIJ4NrM3TZEm7+4VGfHCqDZ+ESWy4ljZC1C91xi7yB2ogzZy igVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688379438; x=1690971438; 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=2qF/Z9+zgr+HRi5gA8P3eTX+di+A7NJtnLcplKmqPHM=; b=eCxb1WO4Ezpje3MkPACqNSs7YWzl9PY89KGsGjm8JqLf4HEIBeBRMM6ECmnoeiZHqY TfNwpYEEyYcXEwCNx/qMuV/pFb79R/ipA3+wUUBA4Nh944ox0GjPwCkSmCycvgRLWutr oLh8lfigg/KAf0xpyL7qhpfeFlFVz/Ip3QpRMeV40BqGCUTi7GBjnsZdDVi2WFTtv+Or L7ET0M6hdu9fvG9lDrutDkkX9giF7+4pf4wl844F8f+JrMEnBUtg75TiIDx6dqoDA+va zV3BzRRYUbMwIU7e3gFV9t3bJI0lp01XVD0D0qV/Xqc4fezlEkrTVTHsXxu/8njwct5o XigQ== X-Gm-Message-State: ABy/qLbHo6KJ31T0+KqokXx1KHEpqul+I88+TViqk3KSGv3FuEoDPWTD DvianHlTDKXL5pXFsdoAdg2Iejtqdhe7iQ== X-Google-Smtp-Source: APBJJlFPGrx28Clm+D1IcqgxbKzBonhfyN/mO24Co5uQ6gs9tVrXC0iC9s0IFt1YBiIT1DLSO1nidw== X-Received: by 2002:a05:6358:e822:b0:134:e631:fd2b with SMTP id gi34-20020a056358e82200b00134e631fd2bmr6242746rwb.0.1688379438244; Mon, 03 Jul 2023 03:17:18 -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 1/4] target/ppc: Add LPAR-per-core vs per-thread mode flag Date: Mon, 3 Jul 2023 20:16:57 +1000 Message-Id: <20230703101700.24064-2-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230703101700.24064-1-npiggin@gmail.com> References: <20230703101700.24064-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::32c; envelope-from=npiggin@gmail.com; helo=mail-ot1-x32c.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: 1688379486913100003 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 Tested-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- hw/ppc/spapr_cpu_core.c | 2 ++ target/ppc/cpu.h | 3 +++ target/ppc/cpu_init.c | 12 ++++++++++++ target/ppc/translate.c | 16 +++++++++++++--- 4 files changed, 30 insertions(+), 3 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/translate.c b/target/ppc/translate.c index db0ba49bdc..10598cde40 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -256,6 +256,16 @@ static inline bool gen_serialize_core(DisasContext *ct= x) } #endif =20 +static inline bool gen_serialize_core_lpar(DisasContext *ctx) +{ + /* 1LPAR implies SMT */ + if (ctx->flags & POWERPC_FLAG_SMT_1LPAR) { + return gen_serialize(ctx); + } + + return true; +} + /* SPR load/store helpers */ static inline void gen_load_spr(TCGv t, int reg) { @@ -451,7 +461,7 @@ 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)) { spr_write_CTRL_ST(ctx, sprn, gprn); goto out; } @@ -815,7 +825,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 +834,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 Wed May 15 16:02:53 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=1688379496; cv=none; d=zohomail.com; s=zohoarc; b=diHgafrdrzXIF9MPzC+xG3NuzZGoiU2aX0m1cdt0tG/B+wovvAh4CRu+QblII8cYO6Yywz+InOQ7VtEK7LOHL7gr3JAW35+xhMfi0wU+AfqpZ/Jq0YNPMxMfdh22nBzFmRZOCtCjgHbLBjp0kbjC6vm8rj8fEfQL+bOYQd9SVzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379496; 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=MBViwVhIYzu532EaMl3x0qE7yvkZKt8huP9izDEd8Mg=; b=dHw2DDzXrg60oq1QXt6Rjk2flBND+fB0F/S2Z21rlD00n8QoVZgfOYo6oqj9SjzSfTynZC7oZl76IX3Q5E0Tfb9ZaabXEwU/R7IyXm4fEC74Z5Nbf6lQD+n8Aujzr1kAVjR4vgSgIfNRCpJmyHw4OjlGvsQmlEW1/V2VhCYocb8= 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 1688379496341330.8959654369652; Mon, 3 Jul 2023 03:18:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGd9-0001YH-R2; Mon, 03 Jul 2023 06:18:03 -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 1qGGce-0000Rz-2r; Mon, 03 Jul 2023 06:17:38 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGcW-0000vs-F0; Mon, 03 Jul 2023 06:17:26 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-666e97fcc60so2433225b3a.3; Mon, 03 Jul 2023 03:17:23 -0700 (PDT) Received: from wheely.local0.net ([118.210.96.60]) by smtp.gmail.com with ESMTPSA id o2-20020aa79782000000b006826c9e4397sm3887727pfp.48.2023.07.03.03.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688379443; x=1690971443; 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=MBViwVhIYzu532EaMl3x0qE7yvkZKt8huP9izDEd8Mg=; b=X5n2trSOmUkNSxPQP2fb3cBMPsbET8APQ6T0s+u/Mr8U0qEYAmCsVxuCmIPSx4G1w1 J6DDSvBZBY2rEF/+zxAa/w6ppxFphBYhmBrqzCzD1NPQsIPNctp5+UhI8zUuvJ5EbCM+ GdpHh/TbsFr2X/uOjtzF8c5u+QYHYHI5mJm1Gwzzr9YyC8Ygl1S8OQwxGdxTkYzeUmu3 PjBLc8CNaTSA5IwvQDb0VRUrsHJ+pJ2vT3DPbA+HuWw5tBqdAGypShZKuAeCt4K05Pch wEUe0p6r/y8w9Zp4TJG2sGFS80FuVU6b5F5FWa/IIs76OvmwVzPNGikjDhm5rhv63gJ6 0qqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688379443; x=1690971443; 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=MBViwVhIYzu532EaMl3x0qE7yvkZKt8huP9izDEd8Mg=; b=cEKkWp3J9IZunyEii1271Irh6n4jX/odp3dPs5wWd4oT4O9ess5UO9ajK1jedNZoBe NKfD9BH32xvzoNYuO+P6BcvATv0nv5XKF22qX+VPZbSVZZQli/RCBd7F6CpSNGH+fxM5 Oxo5+AT5mf31jShz1wW4ymd06qj+qreRa6uJ+/hAqsAERgxQU06jCPK1KtpqavQjVDOr Nj/DbSYlcy/mwrFRzrwjLDhSGh5Mf124V43STNAO6VP54hYdaiBAoZxwgM+mQ5Tg52g2 7hQ/wrdsFsqKGVjDrjR+Wsaqta01kN1I1abFZpXOMESXs3qhh8dMWsmb+W4M3HAmiXj0 cXOQ== X-Gm-Message-State: AC+VfDxyDLAVLdzrJWYco3kJ55JSE2rSvmFsT5TMoOJzBP2d4MT2eE8I akOfcQv7f8xwElJ0/szfgb0= X-Google-Smtp-Source: ACHHUZ4+nGhPox82F7rSQKFRGvWS0Edahs5qynVxa4CtbWtBGpiNh1oAen63J9vW8+4lMaMN41OzeQ== X-Received: by 2002:a05:6a20:7d81:b0:11f:4707:7365 with SMTP id v1-20020a056a207d8100b0011f47077365mr7046720pzj.38.1688379442719; Mon, 03 Jul 2023 03:17:22 -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 2/4] target/ppc: SMT support for the HID SPR Date: Mon, 3 Jul 2023 20:16:58 +1000 Message-Id: <20230703101700.24064-3-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230703101700.24064-1-npiggin@gmail.com> References: <20230703101700.24064-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::42e; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42e.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: 1688379497422100007 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. 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 1f1af21f33..0da335472e 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 10598cde40..07c491df62 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -448,6 +448,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 Wed May 15 16:02:53 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=1688379495; cv=none; d=zohomail.com; s=zohoarc; b=i56pjB2fZHXbiFasDWMQzfZEimaPWt1KiqOFlBtnQ/+rnW7nG3uwM5E2swJcB67xZESykurd4o5+Kx/x5vWCSiC4sovgjZ/X+YBup949tS/k6yNIZitWNCOlSI6mwMu3MPPr4xI3hZpknnL6L9/hONn1QbhiWQ1aCXZSgHHQ54E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379495; 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=gDDgIXZ0Dz48EHlggB8LitElzh77PIq0t2sx1HDcbcw=; b=H7Z273nvoFP7xZrT68sXyYnkg7104wDzAT2E7fpzYO8Gh2xKqgCBnqtn7m5vbJRnG+TdVwYCJ0X/smLtxn26d0J8sMeNi7OXbhkCHoK8iJgqushpCEvDacYHDl8gFFf+8wPhLKR5Bp/htgB631dJW0gpPNEI3e1p2DbX4ywon20= 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 1688379495493326.00472370643286; Mon, 3 Jul 2023 03:18:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGd8-0001QB-PA; Mon, 03 Jul 2023 06:18:02 -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 1qGGcf-0000S2-Sj; Mon, 03 Jul 2023 06:17:38 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGcd-0000wD-Sv; Mon, 03 Jul 2023 06:17:33 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-666683eb028so2118266b3a.0; Mon, 03 Jul 2023 03:17:28 -0700 (PDT) Received: from wheely.local0.net ([118.210.96.60]) by smtp.gmail.com with ESMTPSA id o2-20020aa79782000000b006826c9e4397sm3887727pfp.48.2023.07.03.03.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688379447; x=1690971447; 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=gDDgIXZ0Dz48EHlggB8LitElzh77PIq0t2sx1HDcbcw=; b=AFLC93dSgVztL0beEf59Odq/gG7r9gSzh84iSGNXehpd1fPNRuYjZG1lTT3BlnxZza eoQGXdnFKyfHnh4VrEY1YBWH5Ye3Dn5GjIW49E/YW1nEfF7Zrl3UOCb+omYQfBX7LF0t coHwprjk0qmySwYmkfxHKjJrTNThM4SAX4GFBu+k6z1dnHbqCR2o2vyU9YJPIf2xFNnb apz1mhLjBwYXJmrN/d4gMpUzQf3u++R0glnrixDnCtIfUXNvlBvCaBivCmzNtw4rekGv 3d+9K6QZMiy1sRNWHhMDcCFggw7JDPEMRn/yDXTzTCnfsEGoLnFaGoMCohVPssBpwdNz noNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688379447; x=1690971447; 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=gDDgIXZ0Dz48EHlggB8LitElzh77PIq0t2sx1HDcbcw=; b=S0tlU69FXov3fe9oFGZU3k/bZMEInL6Zq1KEIZ9JpIdeY1Q68myOTgHbsL+2favzy4 xXAAdj/QbfNVzcHvRB2EgJfMMB+Zw3qPzfQPWXQT/yq26yqj7Bgs28qCOoJFXIbKC0LG Z3oiN/3m8rYmOwIEtOnedWjO4IQt1S65H37BTK2TuHACm4N5ukuHUdxDrrKrq4yAoOLA KgT+rrS4Etmt/x5ORlxRjBcD05yMPY1owykExJEpLCRlHT7QWiyvcTQvjJz1xGMg9W24 /JBSgnkVjsf0L4yUr1WjKcjH0oEQ5wRa4HORMH5mMGqmP6o/cRdrqp4RkR7vHNjE9cqo aNwA== X-Gm-Message-State: ABy/qLaHMqRm9P0jE4846qikFAjcL/NckS0vMAz1g+Z7Qjyy+Mipc2Ah 5+Z2yhZtLDvAjMku7OfA4ys= X-Google-Smtp-Source: APBJJlFovDia4jCIKo69Ate6rA7lPu3fsiZa9vuoRLqft062DOzcd3MElXBjwL3jCjkVI20WH08TxA== X-Received: by 2002:a05:6a00:2da0:b0:668:8596:752f with SMTP id fb32-20020a056a002da000b006688596752fmr10915414pfb.4.1688379447458; Mon, 03 Jul 2023 03:17:27 -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 3/4] ppc/pnv: SMT support for powernv Date: Mon, 3 Jul 2023 20:16:59 +1000 Message-Id: <20230703101700.24064-4-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230703101700.24064-1-npiggin@gmail.com> References: <20230703101700.24064-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::42b; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42b.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: 1688379496898100001 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 --- hw/ppc/pnv.c | 12 ++++++++++++ hw/ppc/pnv_core.c | 13 +++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index fc083173f3..f599ccad1d 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 0bc3ad41c8..acd83caee8 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -167,12 +167,13 @@ static const MemoryRegionOps pnv_core_power9_xscom_op= s =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 @@ -188,11 +189,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 */ @@ -241,7 +238,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 Wed May 15 16:02:53 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=1688379484; cv=none; d=zohomail.com; s=zohoarc; b=eKz6uDVVzrLdCj+YjldZt3SpoHrNienVA67VvnBBVDb2nUE/nczo64bs3gGfOL2RMWf8hY8aez+PM5uEnVq/7h01UEMcDfS2/oTa0sUKRWTPf/4V65sO6BTVaW2ymSqgKnF/FSMVUhNtUw7Yj5RCQxBM2JLmZeyVVuHGr8BmyHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688379484; h=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=b2gt1lnUq8y40pcxU1eigEsqaAQ/li7F9tt52IsECqI=; b=GLcu/6u3cq7uZYJsgh6Un9WtNs2FEWRjdw3/oNCb7GLzEKvXHKx29/57MPAJxjDg3r1e6/VpPMbyfDRmY8usnCwiqe76PvaF2w/koLocYdjNrZf6w6E5U6Q0tzTxjkFcidwZ4eMGUnx1eJv46GqhAHSMJnw7L/Ou/fZl0W7TQpA= 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 1688379484850742.5460157466671; Mon, 3 Jul 2023 03:18:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGcx-000105-46; Mon, 03 Jul 2023 06:17:51 -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 1qGGci-0000SM-RC; Mon, 03 Jul 2023 06:17:38 -0400 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGcg-0000wf-Db; Mon, 03 Jul 2023 06:17:36 -0400 Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-3a1ebb79579so2978368b6e.3; Mon, 03 Jul 2023 03:17:33 -0700 (PDT) Received: from wheely.local0.net ([118.210.96.60]) by smtp.gmail.com with ESMTPSA id o2-20020aa79782000000b006826c9e4397sm3887727pfp.48.2023.07.03.03.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 03:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688379453; x=1690971453; 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=b2gt1lnUq8y40pcxU1eigEsqaAQ/li7F9tt52IsECqI=; b=WYMqy7k2rrrarWhOw2NKP8clGg3NzeI1xYnwyuY+PhLQOM4Ei0VWyhLGUgGm2Gi8YB l6ADfQ2pUsSlwaAEULlgaENbAAX59MfYdKwuWYfqsQqcFknoP86VubkPh1b8WDE+chqH nxkL5rfmvFmW2b6O5rGJAofQ/CDIof2ZHzn+eMZNVY2DDtx/Nm1jgBErm+AmjdQXtq1Q meQ1L90/CcgNu09XuL8XJfhRHYrL5HWiYooyOTVafeuy7UIRX6gk28QWj/t/TK5utobA YxySJd1Y+ZbFHUfH0UwNTQVABvw3dtaKZwKV15zUUGXlUKn03hHnMfSBZ9471HdPZrzC Gy6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688379453; x=1690971453; 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=b2gt1lnUq8y40pcxU1eigEsqaAQ/li7F9tt52IsECqI=; b=WOWzArFOuQpvShMyfnOFPowqTI+J6TYfXQbWi02xJbaPGOZlsEEd/kJ1hChwqq9jul ktGHpZ9NP33mAd8VXsjj2HEWrWTbZpiICP5xgoffQNCxpC4TYupsrIvoQ+WknMNkg8Ki MdESiVxTA1wKRaWgxYXco41Sk7Dtm1Ic08hBf6CY29IP1CEd+1257ZbIr0wL2yzeLAx6 LvMK94dUAS5qbFkfqqp44Gi4PBNAbr1HRdwUiY4XKjYAGkmzw0St04GjH2Kl1Z/0fNNH lYZpyjbWswiKXmM4AQWGQuwT4N2d+oVttSpySidMOpcD8XFeOQol75PlL/orYEiXgqwN UdVg== X-Gm-Message-State: AC+VfDwg8Rn4lupctgPG8G1hUHY5esPlzZgfPJ0VK/oF5+jLCEHbydHs iYKblGqEDNDXLX7g+9gxJG0= X-Google-Smtp-Source: ACHHUZ6eIdVbzGqzw/cp23E8w/hdiwwJc4NdHXGXh4zKe0PbmqAOAtglKN9uHagsE5RL6nphDlw++Q== X-Received: by 2002:aca:1a12:0:b0:3a3:613b:2787 with SMTP id a18-20020aca1a12000000b003a3613b2787mr8951525oia.32.1688379453014; Mon, 03 Jul 2023 03:17:33 -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, Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Beraldo Leal Subject: [PATCH 4/4] tests/avocado: Add powernv machine test script Date: Mon, 3 Jul 2023 20:17:00 +1000 Message-Id: <20230703101700.24064-5-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230703101700.24064-1-npiggin@gmail.com> References: <20230703101700.24064-1-npiggin@gmail.com> MIME-Version: 1.0 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::232; envelope-from=npiggin@gmail.com; helo=mail-oi1-x232.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: 1688379486288100001 Content-Type: text/plain; charset="utf-8" This copies ppc_pseries.py to start a set of powernv tests, including a Linux boot test for the newly added SMT mode. Signed-off-by: Nicholas Piggin --- tests/avocado/ppc_powernv.py | 86 ++++++++++++++++++++++++++++++++++++ 1 file changed, 86 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..f72e87bc70 --- /dev/null +++ b/tests/avocado/ppc_powernv.py @@ -0,0 +1,86 @@ +# 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', '8,threads=3D4,cores=3D2,sockets=3D1') + # 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 1 node, 8 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