From nobody Fri Oct 18 06:20:31 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=1721147258; cv=none; d=zohomail.com; s=zohoarc; b=Cx1n3qIYjiZ2I5S0uNbDl/5GTi9jWIVgvvxyHcVVKEHkxbylXFpL72OuhJjEs15X92YUMes8BciA4TxK//G7VDJeTw51xvCE6fgrNEF2JyEgJr8mTYipGT/YPUIlGwNprocrrwpHxHaruONkjuWXKqIucI9Q2xfK4zCwXfKSd8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147258; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=k5y4TKaDDHvMsX8pNSb4QjcSx4fOTcaEPBO+qYDjTJY=; b=JWNCR2pDZ5fGh5to17sjNQy9vIHby1xGQbATDjTeQq5FEXyydwnFmLjn90OeajVTq6WjkmhH76Lff7I1j3zXCpS70/1YVNRzQ51vQz2DeIjdfLvNTxJwPC7+Uy54n6PIuaBT9kNbMn5pkQ8+r9D6jNzJQn/CBShof2MAoOKIjS4= 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 1721147258341378.4012133245262; Tue, 16 Jul 2024 09:27:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl14-0006DQ-3T; Tue, 16 Jul 2024 12:27: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 1sTl0f-0005rz-CG; Tue, 16 Jul 2024 12:26:38 -0400 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl0a-0006FP-G8; Tue, 16 Jul 2024 12:26:37 -0400 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-25e076f79d5so2781190fac.2; Tue, 16 Jul 2024 09:26:31 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147190; x=1721751990; darn=nongnu.org; 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=k5y4TKaDDHvMsX8pNSb4QjcSx4fOTcaEPBO+qYDjTJY=; b=RD3ZFyuKvDlRFYef+Mn/zBkdvonkqGM0awJ6crQQ71fuR8RmW7QpbbnKUVMFOhMPb7 jQumXnQh7UueZnxB1ByPZNJ2GxjXwyf0cxk6jwplR9bG91Q19wkpovkA2yKPp+qzpQ5X RMJvlT/KVwLA/7SOzRYdJfg4pIilQHTGi4oDf6jEMFA51XeuSVXhCQPBHnaXn+xTIq6p 1PoLV+6rY+vqd1REh6koQAO5Ga8Kw5ZbthBGxyNFLWkM63WFJ8saNdTH6T5Is/Kl741X eTeBam6wFrp6iV0QjrNBWWNNiiqvGQY985ge3DUsh+CgcOh1Gypnm+8zETOw7Ka2wiTN YZjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147190; x=1721751990; 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=k5y4TKaDDHvMsX8pNSb4QjcSx4fOTcaEPBO+qYDjTJY=; b=Bkb8ulTweBWFC4O9485Xri/d4EGifIrMPF4eA87upRa2ORK8GM5OD8DP3CHWg/zBHn 5rUAsF7asCU9uQTYSj2d88CIHxmZ2unGuUf4HeZ3y3bdGkpRR8fgzhjgnGSxS+ouAYWW cwxnE1FDF3AQ6YUM0s7xfXB+h30bCyMeG2k9OU4OEMoNcKP6+mlBayerz2flQCb+2EUX sD+quXOnHebw9q8RNaOgdkJvdHO2CCqhrMT46L/EpC0ALG5EgclZjxJLngjJztYTsRf6 bHuZqIbizfUXmvfhbE4q7keWNpBYqkH5FOvyGzmw6atMAqT1E/KH1Zm7xGbfSbBs6OTc 0UuA== X-Forwarded-Encrypted: i=1; AJvYcCVDhq+pTMGB884A3WxqVDWL/c7g4B4gpwXsH1Djt6v95ILZvUAKHLV8c412LFCNjXfQ8e6X8cFP2zR0LAET7CUYGgDko30= X-Gm-Message-State: AOJu0YyW6Tw98tVSk6u5QYafCSWvVfj9Jmjyisub8U5g2HvAAxqnJb4S Uw4T812vX+eRWQt1A7aHRp4fayCIobNRQvu5JiiDG3os/GWe/WoNDPGMVg== X-Google-Smtp-Source: AGHT+IEmdV6pxq49/eBFovU3BVZllefi3rIf7h6Ct84ZQxNwQmPJhQRXPrOOVfgnK/cQEwpfTnXFxw== X-Received: by 2002:a05:6870:c6a1:b0:25d:efdb:ae23 with SMTP id 586e51a60fabf-260bddd9905mr2117907fac.27.1721147189865; Tue, 16 Jul 2024 09:26:29 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH v3 01/19] target/ppc: Fix msgsnd for POWER8 Date: Wed, 17 Jul 2024 02:25:57 +1000 Message-ID: <20240716162617.32161-2-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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=2001:4860:4864:20::2e; envelope-from=npiggin@gmail.com; helo=mail-oa1-x2e.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 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: 1721147260394116600 Content-Type: text/plain; charset="utf-8" POWER8 (ISA v2.07S) introduced the doorbell facility, the msgsnd instruction behaved mostly like msgsndp, it was addressed by TIR and could only send interrupts between threads on the core. ISA v3.0 changed msgsnd to be addressed by PIR and can interrupt any thread in the system. msgsnd only implements the v3.0 semantics, which can make multi-threaded POWER8 hang when booting Linux (due to IPIs failing). This change adds v2.07 semantics. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- target/ppc/excp_helper.c | 74 ++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 0a9e8539a4..5368bf2ff3 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -3007,6 +3007,41 @@ static inline bool dbell_bcast_subproc(target_ulong = rb) return (rb & DBELL_BRDCAST_MASK) =3D=3D DBELL_BRDCAST_SUBPROC; } =20 +/* + * Send an interrupt to a thread in the same core as env). + */ +static void msgsnd_core_tir(CPUPPCState *env, uint32_t target_tir, int irq) +{ + PowerPCCPU *cpu =3D env_archcpu(env); + CPUState *cs =3D env_cpu(env); + uint32_t nr_threads =3D cs->nr_threads; + + if (!(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + nr_threads =3D 1; /* msgsndp behaves as 1-thread in LPAR-per-threa= d mode*/ + } + + if (target_tir >=3D nr_threads) { + return; + } + + if (nr_threads =3D=3D 1) { + ppc_set_irq(cpu, irq, 1); + } else { + CPUState *ccs; + + /* Does iothread need to be locked for walking CPU list? */ + bql_lock(); + THREAD_SIBLING_FOREACH(cs, ccs) { + PowerPCCPU *ccpu =3D POWERPC_CPU(ccs); + if (target_tir =3D=3D ppc_cpu_tir(ccpu)) { + ppc_set_irq(ccpu, irq, 1); + break; + } + } + bql_unlock(); + } +} + void helper_book3s_msgclr(CPUPPCState *env, target_ulong rb) { if (!dbell_type_server(rb)) { @@ -3027,6 +3062,13 @@ void helper_book3s_msgsnd(CPUPPCState *env, target_u= long rb) return; } =20 + /* POWER8 msgsnd is like msgsndp (targets a thread within core) */ + if (!(env->insns_flags2 & PPC2_ISA300)) { + msgsnd_core_tir(env, rb & PPC_BITMASK(57, 63), PPC_INTERRUPT_HDOOR= BELL); + return; + } + + /* POWER9 and later msgsnd is a global (targets any thread) */ cpu =3D ppc_get_vcpu_by_pir(pir); if (!cpu) { return; @@ -3073,41 +3115,13 @@ void helper_book3s_msgclrp(CPUPPCState *env, target= _ulong rb) */ void helper_book3s_msgsndp(CPUPPCState *env, target_ulong rb) { - CPUState *cs =3D env_cpu(env); - PowerPCCPU *cpu =3D env_archcpu(env); - CPUState *ccs; - uint32_t nr_threads =3D cs->nr_threads; - int ttir =3D rb & PPC_BITMASK(57, 63); - 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; - } - - if (nr_threads =3D=3D 1) { - ppc_set_irq(cpu, PPC_INTERRUPT_DOORBELL, 1); + if (!dbell_type_server(rb)) { return; } =20 - /* Does iothread need to be locked for walking CPU list? */ - bql_lock(); - THREAD_SIBLING_FOREACH(cs, ccs) { - PowerPCCPU *ccpu =3D POWERPC_CPU(ccs); - uint32_t thread_id =3D ppc_cpu_tir(ccpu); - - if (ttir =3D=3D thread_id) { - ppc_set_irq(ccpu, PPC_INTERRUPT_DOORBELL, 1); - bql_unlock(); - return; - } - } - - g_assert_not_reached(); + msgsnd_core_tir(env, rb & PPC_BITMASK(57, 63), PPC_INTERRUPT_DOORBELL); } #endif /* TARGET_PPC64 */ =20 --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147312; cv=none; d=zohomail.com; s=zohoarc; b=fS4yniDfeleCUFjRl23rKeCfq8kqZJw0D+gD1gUEmzvSsCR/KYzGpUxrqRoMlDhpqbBGkwHqkC6t/vctt3gOLWGrQLnni+vYkNDChnQFazlGi+seDj95BeTK+SQoselQjpYoxwGcU++R2Z0srqvdHmYHEYR/1oZALxIp29IxCeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147312; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0DgZsKqI5Qui8xJrG3nYJqRYaaUiPlIWM1v7RfXcJUQ=; b=AQ/wLyYcb5mCF3qLNliG7hHyg3zNIZOk/0aczj+BQEt5Z0KhAtBSdmZgsGdtlY+dmYBZDXHyG0gAd0CQAWFufhmCq/Dy/L/COTDTZe21ObUBlpteue1/LOalOKgGtzVteuu0hB5XiI2is/azKMjXO1XAiAoAqfCBrlPtfss1uD4= 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 1721147312343868.2284479982881; Tue, 16 Jul 2024 09:28:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl21-0008TV-Jg; Tue, 16 Jul 2024 12:28: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 1sTl0j-0005ve-I3; Tue, 16 Jul 2024 12:26:43 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl0e-0006Gt-3p; Tue, 16 Jul 2024 12:26:40 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-70b0ebd1ef9so3770988b3a.2; Tue, 16 Jul 2024 09:26:35 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147193; x=1721751993; darn=nongnu.org; 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=0DgZsKqI5Qui8xJrG3nYJqRYaaUiPlIWM1v7RfXcJUQ=; b=nhxZQ7/rbr+njicxKKOhiof+WFNl2/V0NLwFRcyEb4LcB5I9tM9MEWsoIUr3lOD/bM czcGcOdaM9fXZDHmnf20AF5twMutVfXhYDA0UhgwDUG9yKJc6P1iGYlNo/dbNO+Zicl+ oAT4X/NsHfJdwg9iooepPDiyBZ2tZlKxeqxgD1CG34KOJaGE8+Y47yitiRcodRNLJbNo w/tVD+7+3VE0yFsYRAavsjFYIKh/s6vOR7klxJI3Wg0+kIQV6rP40qqcdEeLKpvhKzqc sPGh6rkioz0ELsU2/bsUa9ugVbsDktsm+F2KGqJb9VPdSFYqhfpLdBvIulyph9KTa1/C b8KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147193; x=1721751993; 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=0DgZsKqI5Qui8xJrG3nYJqRYaaUiPlIWM1v7RfXcJUQ=; b=iwXMYFzcwz3HCeEvDklzO+w//6OHbM502NsjS9lXhqTljxr8nadqCRMo5iKm6uj+ZZ fhHaIHTwRvezybDJ3hryGnsc0YnW0NRsRwbuI+F2O3rIUM9BjqSyCnPKgCU/FMeO4psZ X9wVrlnyhmA+awpNk6FsgxeMgrFN9hDyHvbalPPwwaeGvSe/UhB2+qvUN6pd++JdMNUK kVEIQ41eKqYoBUSsdn6jWFAH7qoMtvtBUSgpHaEDt+KS1cPJZhs83BOCUBiSIWuGbEgp oz/XaMKqrYaaUkrffSumZRm7RwdYtA9rZ1owbhnuyNJuhoygrlDTxEYc53g3QCkjavzJ K12w== X-Forwarded-Encrypted: i=1; AJvYcCV9WBtVl++ckSGMbld59PJqms+7LTCoDkXtgbU4FRua721HiOzIvq5sYamQuDv2aLvk0kmZrHI60qsXuty7Jd3kHobZHhw= X-Gm-Message-State: AOJu0YwjXeZJRRVfgtECeYi7JVfFuw0K3O0/e+n5a2SfxQbISKEM4DK4 TNPVttvkrl8uBS6Rb9Z9/KgePsD8jDynTA7woaBxgIuaFom27M0gsIsFyw== X-Google-Smtp-Source: AGHT+IFQkw43f03d51sDbI8D2NSH4QU3UQGqOY90NaITd8eMjiRBa5H/qykOAJuLIfnRRjD/kAVm9A== X-Received: by 2002:a05:6a00:2384:b0:706:aab7:655 with SMTP id d2e1a72fcca58-70c2e9bb1ecmr3393091b3a.26.1721147193467; Tue, 16 Jul 2024 09:26:33 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v3 02/19] ppc/pnv: Add pointer from PnvCPUState to PnvCore Date: Wed, 17 Jul 2024 02:25:58 +1000 Message-ID: <20240716162617.32161-3-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::42c; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42c.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, T_SPF_TEMPERROR=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: 1721147312578116600 This helps move core state from CPU to core structures. Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Harsh Prateek Bora Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv_core.h | 1 + hw/ppc/pnv_core.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h index c6d62fd145..29cab9dfd9 100644 --- a/include/hw/ppc/pnv_core.h +++ b/include/hw/ppc/pnv_core.h @@ -54,6 +54,7 @@ struct PnvCoreClass { #define PNV_CORE_TYPE_NAME(cpu_model) cpu_model PNV_CORE_TYPE_SUFFIX =20 typedef struct PnvCPUState { + PnvCore *pnv_core; Object *intc; } PnvCPUState; =20 diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index f40ab721d6..2da271ffb6 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -278,6 +278,7 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) pc->threads =3D g_new(PowerPCCPU *, cc->nr_threads); for (i =3D 0; i < cc->nr_threads; i++) { PowerPCCPU *cpu; + PnvCPUState *pnv_cpu; =20 obj =3D object_new(typename); cpu =3D POWERPC_CPU(obj); @@ -288,6 +289,8 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) object_property_add_child(OBJECT(pc), name, obj); =20 cpu->machine_data =3D g_new0(PnvCPUState, 1); + pnv_cpu =3D pnv_cpu_state(cpu); + pnv_cpu->pnv_core =3D pc; =20 object_unref(obj); } --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147333; cv=none; d=zohomail.com; s=zohoarc; b=CxVocpJRhlpdgkSe9CAwQeQ4sRpUmNTgOAsOTDzciYXP/j9QyfwqJmPm0aHtd8a/a3IW57X6JGIfmv3FyKzwOIG2x06NywJIAWp4kqLNZlD17zWlxZaR6tpCN41KuBIx1pWy8pTtKi+s2ZlbfiOFfLJG9+KlnIDk0mMWNqqGdIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147333; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JXcN7rc21Iq6Bcn9S0KBwtXpswBbDILgo+A0ACNS488=; b=DbJe49p6SP5Hdf4/ZBiDnC0KyrVjp1wNx+dBOc2dzxDpctioyEonTJxTJqbTDrcaEFqNha3OuVUtEaTPwHl6NJZ3IlIWUk1oJ8fjM4jaIxsZwvaQHPvap+fLc0KJi7qQ/WUbXW0h9e/TXTo92qax96pNBAuHOPOpI2wXmLBm6FA= 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 1721147333581205.19606946456838; Tue, 16 Jul 2024 09:28:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl1x-0008KY-Rp; Tue, 16 Jul 2024 12:27:59 -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 1sTl0j-0005vf-Si; Tue, 16 Jul 2024 12:26:43 -0400 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl0h-0006I7-Ne; Tue, 16 Jul 2024 12:26:41 -0400 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-5c791729c36so3150827eaf.3; Tue, 16 Jul 2024 09:26:38 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147197; x=1721751997; darn=nongnu.org; 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=JXcN7rc21Iq6Bcn9S0KBwtXpswBbDILgo+A0ACNS488=; b=I1l6dCuM0ffQqlC5jVS+6UsASXQWt7Vdic67h4PnrNZgI9PMR4PJ2q//QLrhDV14fN RGGS0z9C0bJ5tGObCIQkri6gd7ABpJ0HnoBNnWziqos5DdO3OyGCZJArV03nX8IIK7sz XolDd8EL/89zx4aLqAxjEdn97WabCGGNFDB1bI68JiYP0Awf3+a3tvSywR+ypXIoP1GP r0LH9b+yHRlWN7kdVwm9wCHikZQttokrW30q64QzRfBL+KPAlhbn8c4R1LbD7Obv11Nc FyKknuP/qSspe9Amt4B7DgPbD0TykkO8kSARkxwwsJtvLZwnDtcGm5nD5eUWqzAZOZtJ t7yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147197; x=1721751997; 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=JXcN7rc21Iq6Bcn9S0KBwtXpswBbDILgo+A0ACNS488=; b=rsdIOi5yVgi87Z2qYVFkurL8jHxN0rUR1G2FDJpoXtzg4cMo0jAxqmjQdyWEk/HI+2 HTOlkLZJf7F+7DAZN2QTVdJbKWzj5/8YYBca50ijEeW5Pj2bxRGait3uiwVozjh8Wzor 92YOOHgdMWzXysvGhWMKZmgDOMRdo6HWdxYeK0MJQ3RuCVStgcFUXCwBnmGDCSnNKOgK nNTqnN7xGgTFZuWZzyywQpuGBlKchTQnHW1mHO4IkJq7Nl1Aixm9kPVraCWXylBmkYLW a/39ek++nADJlMjGpg3ULal+yQxIHYOINiypGgV0MxvWNJOH0Qg5/77OA9Px/vCvnBpY OyVg== X-Forwarded-Encrypted: i=1; AJvYcCXUPo4aAozkfVlV1caF2lFw81DHb4QjqnMftrM6WvS7dmoVMMUVi8T/MKkWf7aThpdVKck3XPMWT2Tfl8Ga0/dj2txNeBw= X-Gm-Message-State: AOJu0YzqtcLeHnfdmkdTG/sGRwnU9rP/Oje/qAu0jPJiVc6y1MuFmXXg H+90WIXh63j6jcnglAYGS9DPI85kZVz1kkUvXkYm8e3oRd2Q9NXvYnYm5A== X-Google-Smtp-Source: AGHT+IF8fK6LegX6ZMXXvJcYusNTLZs0GAOPufEQNnuHSu4Zjbw6ZdKhzoZGDsQV99Qfbn+l8yaJnQ== X-Received: by 2002:a05:6870:ac14:b0:24c:ac7e:8a5c with SMTP id 586e51a60fabf-260bddbaab4mr2111072fac.21.1721147196859; Tue, 16 Jul 2024 09:26:36 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH v3 03/19] ppc/pnv: Move timebase state into PnvCore Date: Wed, 17 Jul 2024 02:25:59 +1000 Message-ID: <20240716162617.32161-4-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::c2e; envelope-from=npiggin@gmail.com; helo=mail-oo1-xc2e.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 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: 1721147334689116600 Content-Type: text/plain; charset="utf-8" The timebase state machine is per per-core state and can be driven by any thread in the core. It is currently implemented as a hack where the state is in a CPU structure and only thread 0's state is accessed by the chiptod, which limits programming the timebase side of the state machine to thread 0 of a core. Move the state out into PnvCore and share it among all threads. Reviewed-by: Harsh Prateek Bora Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv_core.h | 17 ++++++++++++ target/ppc/cpu.h | 21 -------------- hw/ppc/pnv_chiptod.c | 7 ++--- target/ppc/timebase_helper.c | 53 ++++++++++++++++++++---------------- 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h index 29cab9dfd9..ffec8516ae 100644 --- a/include/hw/ppc/pnv_core.h +++ b/include/hw/ppc/pnv_core.h @@ -25,6 +25,20 @@ #include "hw/ppc/pnv.h" #include "qom/object.h" =20 +/* Per-core ChipTOD / TimeBase state */ +typedef struct PnvCoreTODState { + int tb_ready_for_tod; /* core TB ready to receive TOD from chiptod */ + int tod_sent_to_tb; /* chiptod sent TOD to the core TB */ + + /* + * "Timers" for async TBST events are simulated by mfTFAC because TFAC + * is polled for such events. These are just used to ensure firmware + * performs the polling at least a few times. + */ + int tb_state_timer; + int tb_sync_pulse_timer; +} PnvCoreTODState; + #define TYPE_PNV_CORE "powernv-cpu-core" OBJECT_DECLARE_TYPE(PnvCore, PnvCoreClass, PNV_CORE) @@ -38,6 +52,9 @@ struct PnvCore { uint32_t pir; uint32_t hwid; uint64_t hrmor; + + PnvCoreTODState tod_state; + PnvChip *chip; =20 MemoryRegion xscom_regs; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 2015e603d4..c78d6ca91a 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1196,21 +1196,6 @@ DEXCR_ASPECT(SRAPD, 4) DEXCR_ASPECT(NPHIE, 5) DEXCR_ASPECT(PHIE, 6) =20 -/*************************************************************************= ****/ -/* PowerNV ChipTOD and TimeBase State Machine */ -struct pnv_tod_tbst { - int tb_ready_for_tod; /* core TB ready to receive TOD from chiptod */ - int tod_sent_to_tb; /* chiptod sent TOD to the core TB */ - - /* - * "Timers" for async TBST events are simulated by mfTFAC because TFAC - * is polled for such events. These are just used to ensure firmware - * performs the polling at least a few times. - */ - int tb_state_timer; - int tb_sync_pulse_timer; -}; - /*************************************************************************= ****/ /* The whole PowerPC CPU context */ =20 @@ -1291,12 +1276,6 @@ struct CPUArchState { uint32_t tlb_need_flush; /* Delayed flush needed */ #define TLB_NEED_LOCAL_FLUSH 0x1 #define TLB_NEED_GLOBAL_FLUSH 0x2 - -#if defined(TARGET_PPC64) - /* PowerNV chiptod / timebase facility state. */ - /* Would be nice to put these into PnvCore */ - struct pnv_tod_tbst pnv_tod_tbst; -#endif #endif =20 /* Other registers */ diff --git a/hw/ppc/pnv_chiptod.c b/hw/ppc/pnv_chiptod.c index 3831a72101..1e41fe557a 100644 --- a/hw/ppc/pnv_chiptod.c +++ b/hw/ppc/pnv_chiptod.c @@ -364,8 +364,7 @@ static void pnv_chiptod_xscom_write(void *opaque, hwadd= r addr, qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: xscom write reg" " TOD_MOVE_TOD_TO_TB_REG with no slave target\n"= ); } else { - PowerPCCPU *cpu =3D chiptod->slave_pc_target->threads[0]; - CPUPPCState *env =3D &cpu->env; + PnvCore *pc =3D chiptod->slave_pc_target; =20 /* * Moving TOD to TB will set the TB of all threads in a @@ -377,8 +376,8 @@ static void pnv_chiptod_xscom_write(void *opaque, hwadd= r addr, * thread 0. */ =20 - if (env->pnv_tod_tbst.tb_ready_for_tod) { - env->pnv_tod_tbst.tod_sent_to_tb =3D 1; + if (pc->tod_state.tb_ready_for_tod) { + pc->tod_state.tod_sent_to_tb =3D 1; } else { qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: xscom write r= eg" " TOD_MOVE_TOD_TO_TB_REG with TB not ready t= o" diff --git a/target/ppc/timebase_helper.c b/target/ppc/timebase_helper.c index 39d397416e..52f9e6669c 100644 --- a/target/ppc/timebase_helper.c +++ b/target/ppc/timebase_helper.c @@ -19,6 +19,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "hw/ppc/ppc.h" +#include "hw/ppc/pnv_core.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" #include "qemu/log.h" @@ -298,8 +299,17 @@ static void write_tfmr(CPUPPCState *env, target_ulong = val) } } =20 +static PnvCoreTODState *cpu_get_tbst(PowerPCCPU *cpu) +{ + PnvCore *pc =3D pnv_cpu_state(cpu)->pnv_core; + + return &pc->tod_state; +} + static void tb_state_machine_step(CPUPPCState *env) { + PowerPCCPU *cpu =3D env_archcpu(env); + PnvCoreTODState *tod_state =3D cpu_get_tbst(cpu); uint64_t tfmr =3D env->spr[SPR_TFMR]; unsigned int tbst =3D tfmr_get_tb_state(tfmr); =20 @@ -307,15 +317,15 @@ static void tb_state_machine_step(CPUPPCState *env) return; } =20 - if (env->pnv_tod_tbst.tb_sync_pulse_timer) { - env->pnv_tod_tbst.tb_sync_pulse_timer--; + if (tod_state->tb_sync_pulse_timer) { + tod_state->tb_sync_pulse_timer--; } else { tfmr |=3D TFMR_TB_SYNC_OCCURED; write_tfmr(env, tfmr); } =20 - if (env->pnv_tod_tbst.tb_state_timer) { - env->pnv_tod_tbst.tb_state_timer--; + if (tod_state->tb_state_timer) { + tod_state->tb_state_timer--; return; } =20 @@ -332,20 +342,20 @@ static void tb_state_machine_step(CPUPPCState *env) } else if (tfmr & TFMR_MOVE_CHIP_TOD_TO_TB) { if (tbst =3D=3D TBST_SYNC_WAIT) { tfmr =3D tfmr_new_tb_state(tfmr, TBST_GET_TOD); - env->pnv_tod_tbst.tb_state_timer =3D 3; + tod_state->tb_state_timer =3D 3; } else if (tbst =3D=3D TBST_GET_TOD) { - if (env->pnv_tod_tbst.tod_sent_to_tb) { + if (tod_state->tod_sent_to_tb) { tfmr =3D tfmr_new_tb_state(tfmr, TBST_TB_RUNNING); tfmr &=3D ~TFMR_MOVE_CHIP_TOD_TO_TB; - env->pnv_tod_tbst.tb_ready_for_tod =3D 0; - env->pnv_tod_tbst.tod_sent_to_tb =3D 0; + tod_state->tb_ready_for_tod =3D 0; + tod_state->tod_sent_to_tb =3D 0; } } else { qemu_log_mask(LOG_GUEST_ERROR, "TFMR error: MOVE_CHIP_TOD_TO_T= B " "state machine in invalid state 0x%x\n", tbst); tfmr =3D tfmr_new_tb_state(tfmr, TBST_TB_ERROR); tfmr |=3D TFMR_FIRMWARE_CONTROL_ERROR; - env->pnv_tod_tbst.tb_ready_for_tod =3D 0; + tod_state->tb_ready_for_tod =3D 0; } } =20 @@ -361,6 +371,8 @@ target_ulong helper_load_tfmr(CPUPPCState *env) =20 void helper_store_tfmr(CPUPPCState *env, target_ulong val) { + PowerPCCPU *cpu =3D env_archcpu(env); + PnvCoreTODState *tod_state =3D cpu_get_tbst(cpu); uint64_t tfmr =3D env->spr[SPR_TFMR]; uint64_t clear_on_write; unsigned int tbst =3D tfmr_get_tb_state(tfmr); @@ -384,14 +396,7 @@ void helper_store_tfmr(CPUPPCState *env, target_ulong = val) * after the second mfspr. */ tfmr &=3D ~TFMR_TB_SYNC_OCCURED; - env->pnv_tod_tbst.tb_sync_pulse_timer =3D 1; - - if (ppc_cpu_tir(env_archcpu(env)) !=3D 0 && - (val & (TFMR_LOAD_TOD_MOD | TFMR_MOVE_CHIP_TOD_TO_TB))) { - qemu_log_mask(LOG_UNIMP, "TFMR timebase state machine can only be " - "driven by thread 0\n"); - goto out; - } + tod_state->tb_sync_pulse_timer =3D 1; =20 if (((tfmr | val) & (TFMR_LOAD_TOD_MOD | TFMR_MOVE_CHIP_TOD_TO_TB)) = =3D=3D (TFMR_LOAD_TOD_MOD | TFMR_MOVE_CHIP_TOD_TO_TB)) { @@ -399,7 +404,7 @@ void helper_store_tfmr(CPUPPCState *env, target_ulong v= al) "MOVE_CHIP_TOD_TO_TB both set\n"); tfmr =3D tfmr_new_tb_state(tfmr, TBST_TB_ERROR); tfmr |=3D TFMR_FIRMWARE_CONTROL_ERROR; - env->pnv_tod_tbst.tb_ready_for_tod =3D 0; + tod_state->tb_ready_for_tod =3D 0; goto out; } =20 @@ -413,8 +418,8 @@ void helper_store_tfmr(CPUPPCState *env, target_ulong v= al) tfmr &=3D ~TFMR_LOAD_TOD_MOD; tfmr &=3D ~TFMR_MOVE_CHIP_TOD_TO_TB; tfmr &=3D ~TFMR_FIRMWARE_CONTROL_ERROR; /* XXX: should this be cle= ared? */ - env->pnv_tod_tbst.tb_ready_for_tod =3D 0; - env->pnv_tod_tbst.tod_sent_to_tb =3D 0; + tod_state->tb_ready_for_tod =3D 0; + tod_state->tod_sent_to_tb =3D 0; goto out; } =20 @@ -427,19 +432,19 @@ void helper_store_tfmr(CPUPPCState *env, target_ulong= val) =20 if (tfmr & TFMR_LOAD_TOD_MOD) { /* Wait for an arbitrary 3 mfspr until the next state transition. = */ - env->pnv_tod_tbst.tb_state_timer =3D 3; + tod_state->tb_state_timer =3D 3; } else if (tfmr & TFMR_MOVE_CHIP_TOD_TO_TB) { if (tbst =3D=3D TBST_NOT_SET) { tfmr =3D tfmr_new_tb_state(tfmr, TBST_SYNC_WAIT); - env->pnv_tod_tbst.tb_ready_for_tod =3D 1; - env->pnv_tod_tbst.tb_state_timer =3D 3; /* arbitrary */ + tod_state->tb_ready_for_tod =3D 1; + tod_state->tb_state_timer =3D 3; /* arbitrary */ } else { qemu_log_mask(LOG_GUEST_ERROR, "TFMR error: MOVE_CHIP_TOD_TO_T= B " "not in TB not set state 0x%x\n= ", tbst); tfmr =3D tfmr_new_tb_state(tfmr, TBST_TB_ERROR); tfmr |=3D TFMR_FIRMWARE_CONTROL_ERROR; - env->pnv_tod_tbst.tb_ready_for_tod =3D 0; + tod_state->tb_ready_for_tod =3D 0; } } =20 --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147372; cv=none; d=zohomail.com; s=zohoarc; b=N9UNPY/lLIrgF2VOR7xNG/Hz4mcyZQZQQJUIlWy8hrXyY+V523tEJXkaM8sYvgbQTgT4LUFvud31jPyQqksJ7T3cPhFbuXiq3qq9Fcj/NEM61k52dpwMQfRx8vG8m3DJ/O2Km6zF0tNlmefHSQc9hvRmn2beCCKtdouDmmFqxYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147372; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SyhirM3GRw4vaEFR7fdPD23qctfXv4t8r+16JQT6sG0=; b=ePANvPTpRHDwTxDYGrx+L3hvYbddFRdMQkpEnFxfLHfNBlyzVLHJaFPeQYhMjHIrX538yqvSFjoKcOiNKSuNM4DIdoCPdEOAFaoJFGNeeo4xKTgCaz8txXRiELtvJKAWINhgCG3MNyI4YF4030sz89NMattgZ2HAS2Ujh4FQ8MY= 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 1721147372160391.033534094899; Tue, 16 Jul 2024 09:29:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2V-0003hw-K1; Tue, 16 Jul 2024 12:28:31 -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 1sTl0n-0005xw-Nb; Tue, 16 Jul 2024 12:26:48 -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 1sTl0k-0006L6-Te; Tue, 16 Jul 2024 12:26:45 -0400 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-5cce7626c87so1821139eaf.2; Tue, 16 Jul 2024 09:26:42 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147201; x=1721752001; darn=nongnu.org; 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=SyhirM3GRw4vaEFR7fdPD23qctfXv4t8r+16JQT6sG0=; b=P6pmAKKSNNsk4E2vvpl3Tmhggnk8Cj9Yf8HfFcHutaz5YRgoZ5Nf4RyBc6Q0+pMlMx cmvAFNEWDVPsy1rmEen3zKNwayoDc3ey3+BmoIzsC2bJHiurPOUlYsXjvtzXwKmO/4X8 w39pgp193SVMVZvjlR2qkForu9R4PDpv03RI6pmWQO+WnR+nYr6fE7/KbHWa5XMJqEsL sNlpFrd2Pn/OO+aGK20gA64nu7NyRLhvMPi3n5iPCDLMMRgpQJZ3J90iFXEkHubAaVzM BRAp/Xtn1ME4f3E4xs3J8tTWE54/jSlQwTWaeF5HsUjKhgP3Y0VL7t5pkyrt0EfMNNNO ubLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147201; x=1721752001; 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=SyhirM3GRw4vaEFR7fdPD23qctfXv4t8r+16JQT6sG0=; b=uC0Mh4qQ+PpMgm1KhnZQwH8MdtRVfdx2A35OGOlsgL3/kIj7gSp8HYtPCAqEjj0hlX 4EBI6vGL2I88PHg+8rLOQedNIm43X0mKa3ExpXQI9tvW8D5ZvcEB5oLTb4DTe3vjSZhi l+TORggVhEMeCiJWxNB202Ua0nEX9N6IXh6fJ4cOiENnzAJlKfIlRymOGH2AWgDhc2BA O35xjtsGuo4LBj0Mppn66whHBEHdXR7JRFezdk1un8xQpH7/tLkqkfrkAtubJUMRBwMr 9cz0prjaSg0eeJigbPhuarJeDVTUnzu9sra+bhPvAJscv2mf87RyQh7a+UmygpowEaNr jzzA== X-Forwarded-Encrypted: i=1; AJvYcCXneEQxVDWFexREytI0AeYXwOgFty0+xqTsDgpXW09WhS2hF6PBFYBZWLEDIo2KY4Vfh64zW3WBcUd4th0U5lXXlHQBrh8= X-Gm-Message-State: AOJu0YyiBKrmeLtP+lpnxVDZQFSqqR0IsfLsXGJE8QGvWN8y2hJOq9SW ZetqA05Ofl29uPRzXYBB3E5tFzrikCzVujgiI8cxA/AydgT7LJs9LqqkFQ== X-Google-Smtp-Source: AGHT+IEuPNCrQtiixPNowUbictzK3rNDu2r+99ZW1Y0beUXoqfG9FkBltyngmkpQ0RAokqluZ/jA9w== X-Received: by 2002:a05:6870:b52b:b0:25e:27a4:4e51 with SMTP id 586e51a60fabf-260bdd82c79mr2131619fac.20.1721147200653; Tue, 16 Jul 2024 09:26:40 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH v3 04/19] target/ppc: Move SPR indirect registers into PnvCore Date: Wed, 17 Jul 2024 02:26:00 +1000 Message-ID: <20240716162617.32161-5-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::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 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: 1721147372831116600 Content-Type: text/plain; charset="utf-8" SPRC/SPRD were recently added to all BookS CPUs supported, but they are only tested on POWER9 and POWER10, so restrict them to those CPUs. SPR indirect scratch registers presently replicated per-CPU like SMT SPRs, but the PnvCore is a better place for them since they are restricted to P9/P10. Also add SPR indirect read access to core thread state for POWER9 since skiboot accesses that when booting to check for big-core mode. Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv_core.h | 1 + target/ppc/cpu.h | 3 -- target/ppc/cpu_init.c | 21 +++++++------- target/ppc/misc_helper.c | 60 ++++++++++++++++++--------------------- 4 files changed, 39 insertions(+), 46 deletions(-) diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h index ffec8516ae..693acb189b 100644 --- a/include/hw/ppc/pnv_core.h +++ b/include/hw/ppc/pnv_core.h @@ -53,6 +53,7 @@ struct PnvCore { uint32_t hwid; uint64_t hrmor; =20 + target_ulong scratch[8]; /* SPRC/SPRD indirect SCRATCH registers */ PnvCoreTODState tod_state; =20 PnvChip *chip; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index c78d6ca91a..95ba9e7590 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1253,9 +1253,6 @@ struct CPUArchState { ppc_slb_t slb[MAX_SLB_ENTRIES]; /* PowerPC 64 SLB area */ struct CPUBreakpoint *ciabr_breakpoint; struct CPUWatchpoint *dawr0_watchpoint; - - /* POWER CPU regs/state */ - target_ulong scratch[8]; /* SCRATCH registers (shared across core) */ #endif target_ulong sr[32]; /* segment registers */ uint32_t nb_BATs; /* number of BATs */ diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index e38f62b08d..164bb62e63 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -5777,16 +5777,6 @@ static void register_power_common_book4_sprs(CPUPPCS= tate *env) SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_core_write_generic, 0x00000000); - spr_register_hv(env, SPR_POWER_SPRC, "SPRC", - SPR_NOACCESS, SPR_NOACCESS, - SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_sprc, - 0x00000000); - spr_register_hv(env, SPR_POWER_SPRD, "SPRD", - SPR_NOACCESS, SPR_NOACCESS, - SPR_NOACCESS, SPR_NOACCESS, - &spr_read_sprd, &spr_write_sprd, - 0x00000000); #endif } =20 @@ -5799,6 +5789,17 @@ static void register_power9_book4_sprs(CPUPPCState *= env) SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, KVM_REG_PPC_WORT, 0); + /* SPRC/SPRD exist in earlier CPUs but only tested on POWER9/10 */ + spr_register_hv(env, SPR_POWER_SPRC, "SPRC", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, SPR_NOACCESS, + &spr_read_generic, &spr_write_sprc, + 0x00000000); + spr_register_hv(env, SPR_POWER_SPRD, "SPRD", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, SPR_NOACCESS, + &spr_read_sprd, &spr_write_sprd, + 0x00000000); #endif } =20 diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index fa47be2298..4d3c1bddd9 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -26,6 +26,7 @@ #include "qemu/main-loop.h" #include "mmu-book3s-v3.h" #include "hw/ppc/ppc.h" +#include "hw/ppc/pnv_core.h" =20 #include "helper_regs.h" =20 @@ -321,11 +322,18 @@ void helper_store_sprc(CPUPPCState *env, target_ulong= val) =20 target_ulong helper_load_sprd(CPUPPCState *env) { + /* + * SPRD is a HV-only register for Power CPUs, so this will only be + * accessed by powernv machines. + */ + PowerPCCPU *cpu =3D env_archcpu(env); + PnvCore *pc =3D pnv_cpu_state(cpu)->pnv_core; target_ulong sprc =3D env->spr[SPR_POWER_SPRC]; =20 - switch (sprc & 0x3c0) { - case 0: /* SCRATCH0-7 */ - return env->scratch[(sprc >> 3) & 0x7]; + switch (sprc & 0x3e0) { + case 0: /* SCRATCH0-3 */ + case 1: /* SCRATCH4-7 */ + return pc->scratch[(sprc >> 3) & 0x7]; default: qemu_log_mask(LOG_UNIMP, "mfSPRD: Unimplemented SPRC:0x" TARGET_FMT_lx"\n", sprc); @@ -334,41 +342,27 @@ target_ulong helper_load_sprd(CPUPPCState *env) return 0; } =20 -static void do_store_scratch(CPUPPCState *env, int nr, target_ulong val) -{ - CPUState *cs =3D env_cpu(env); - CPUState *ccs; - uint32_t nr_threads =3D cs->nr_threads; - - /* - * Log stores to SCRATCH, because some firmware uses these for debuggi= ng - * and logging, but they would normally be read by the BMC, which is - * not implemented in QEMU yet. This gives a way to get at the informa= tion. - * Could also dump these upon checkstop. - */ - qemu_log("SPRD write 0x" TARGET_FMT_lx " to SCRATCH%d\n", val, nr); - - if (nr_threads =3D=3D 1) { - env->scratch[nr] =3D val; - return; - } - - THREAD_SIBLING_FOREACH(cs, ccs) { - CPUPPCState *cenv =3D &POWERPC_CPU(ccs)->env; - cenv->scratch[nr] =3D val; - } -} - void helper_store_sprd(CPUPPCState *env, target_ulong val) { target_ulong sprc =3D env->spr[SPR_POWER_SPRC]; - - switch (sprc & 0x3c0) { - case 0: /* SCRATCH0-7 */ - do_store_scratch(env, (sprc >> 3) & 0x7, val); + PowerPCCPU *cpu =3D env_archcpu(env); + PnvCore *pc =3D pnv_cpu_state(cpu)->pnv_core; + + switch (sprc & 0x3e0) { + case 0: /* SCRATCH0-3 */ + case 1: /* SCRATCH4-7 */ + /* + * Log stores to SCRATCH, because some firmware uses these for + * debugging and logging, but they would normally be read by the B= MC, + * which is not implemented in QEMU yet. This gives a way to get a= t the + * information. Could also dump these upon checkstop. + */ + int nr =3D (sprc >> 3) & 0x7; + qemu_log("SPRD write 0x" TARGET_FMT_lx " to SCRATCH%d\n", val, nr); + pc->scratch[nr] =3D val; break; default: - qemu_log_mask(LOG_UNIMP, "mfSPRD: Unimplemented SPRC:0x" + qemu_log_mask(LOG_UNIMP, "mtSPRD: Unimplemented SPRC:0x" TARGET_FMT_lx"\n", sprc); break; } --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147317; cv=none; d=zohomail.com; s=zohoarc; b=jIG1GR3gq2YhMBVitWu2SwVN4GVWIEI+z/89Rsfak0om8tHlFY2Tex0adth6isBcFxn9BSyMe7tmUUwph7lBc2oh6eC1s6FICl+PRynibh1m2jhR22UCXh98x2r8SU+8lrQh16ETr2ZQ3E8ZER6Kvg+/WlDC+iE0EY993Sle+eo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147317; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7AyDGj3ZDezl1UlUVAm1qZ38iB6LaQ9Gbtb/xnqxjfY=; b=D6zA1dr9PPY3XONYqPTfLEWxF8SrT4QWfMNWJnwFscallAwUamb7qdJJOIyuFvyTwL2Zk28oHUABku9UYLcgIL7GiVwIGCLaEYnT7iXg8O5xMjfvlxK4Uys9E1YH904Y5Ao16RiPs/b/7xAYPvJLQsT0WS/mEMVprItWB3ASrnM= 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 1721147316948950.7445606555018; Tue, 16 Jul 2024 09:28:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2H-0001V9-Qg; Tue, 16 Jul 2024 12:28:18 -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 1sTl0r-00062s-NR; Tue, 16 Jul 2024 12:26:53 -0400 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl0p-0006Mq-CT; Tue, 16 Jul 2024 12:26:49 -0400 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-25dfb580d1fso3071433fac.2; Tue, 16 Jul 2024 09:26:46 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147204; x=1721752004; darn=nongnu.org; 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=7AyDGj3ZDezl1UlUVAm1qZ38iB6LaQ9Gbtb/xnqxjfY=; b=WOF5SNd+FZg40pnHHW/3cCRGKZfWsRo1dHSsrI967tgzOWGc76nHIcXV9/WvBNKNrv eUkCa8nprkKDyeF11aeFvMW+pkqHkmHu41K0fueyrYiSaC0MyBmbmoljxAWWFHANXI0c pMdp9D1M18Buu8zfcSq+RVnPm1vAzSUUfxaI2JjMtf6YU9S2Hsd6ElAA8pe616Fvnn8p THn3cVLD8p5juywADndeC7bdZ1x4uCDfX4Hhi+Jw4NXwVon318R+O3n9fej/Q4/bSo01 bSb3JVYOHsz+MwCGvdNGkglzyuF4/j+jhLq6MjXQR6DWr0agFU/HYvQN2be6Ov9hMIhn i0fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147204; x=1721752004; 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=7AyDGj3ZDezl1UlUVAm1qZ38iB6LaQ9Gbtb/xnqxjfY=; b=gasDmIMDkxV0i51EZX1sb39QaWIRGojej527YdXI+22Tpm3WS+lxwaelrn5W/zlX6U HE9yBTpcT1Ia1b+HKeAeiE0M+mqfEZ+mYkSSAeTMj+XBcZLuDOaV5eJUgga/a56lqqdk 9MLeoV6lT0WhQhSAk+SwrYUqmP1X0GauwDlkc+Z4ypvErVZ7pbrK8H4IfdRl+kYrBXMo mkXrkraFS9wPE26sa1QlSJyO4dRnP2slW0qbSFMdzcljlctlKVo4WCHemf4Gt8bAUNJw P9lRpEFy+MQlkWUybJ1juMagYNoinVvpEJ16kxPnSML9cXYbSiMesHQsRLlpJnGjLNnS HlIg== X-Forwarded-Encrypted: i=1; AJvYcCUvxC9+yBztbEkR2hxg2Q7r2lBkIjBAu3JL2YXXRXygM2cT4B7w+0aDa8szseBe0A9QJ8i1g1AH0AlYwTS/fw484PJAhjs= X-Gm-Message-State: AOJu0YzgIVMA5VNtgyIACChkx28xyH9jjCWNRCmFf9cnbadF4VHp+LCE D+ptSwnL/DTt1vyIanbOSf2Ssd6eFCdCwSOYf+VQ21cNDndhWj9Sq3V0aQ== X-Google-Smtp-Source: AGHT+IGnap7OHpkqVia1tEBlVJieU3uxsgWn4oXVuk9UAbsxckqLafHvp8PgAkrO7VBQuN6hNAOOkQ== X-Received: by 2002:a05:6870:c1d2:b0:259:88b4:976 with SMTP id 586e51a60fabf-260bd9a5652mr2211686fac.43.1721147204414; Tue, 16 Jul 2024 09:26:44 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v3 05/19] ppc/pnv: use class attribute to limit SMT threads for different machines Date: Wed, 17 Jul 2024 02:26:01 +1000 Message-ID: <20240716162617.32161-6-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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=2001:4860:4864:20::30; envelope-from=npiggin@gmail.com; helo=mail-oa1-x30.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 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: 1721147318585116600 Use a class attribute to specify the number of SMT threads per core permitted for different machines, 8 for powernv8 and 4 for powernv9/10. Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Harsh Prateek Bora Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv.h | 1 + hw/ppc/pnv.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 476b136146..1993dededf 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -76,6 +76,7 @@ struct PnvMachineClass { /*< public >*/ const char *compat; int compat_size; + int max_smt_threads; =20 void (*dt_power_mgt)(PnvMachineState *pnv, void *fdt); void (*i2c_init)(PnvMachineState *pnv); diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 7878fed43c..fde51ca946 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -899,6 +899,7 @@ static void pnv_init(MachineState *machine) PnvMachineState *pnv =3D PNV_MACHINE(machine); MachineClass *mc =3D MACHINE_GET_CLASS(machine); PnvMachineClass *pmc =3D PNV_MACHINE_GET_CLASS(machine); + int max_smt_threads =3D pmc->max_smt_threads; char *fw_filename; long fw_size; uint64_t chip_ram_start =3D 0; @@ -997,17 +998,19 @@ static void pnv_init(MachineState *machine) pnv->num_chips =3D machine->smp.max_cpus / (machine->smp.cores * machine->smp.threads= ); =20 - if (machine->smp.threads > 8) { - error_report("Cannot support more than 8 threads/core " - "on a powernv machine"); + if (machine->smp.threads > max_smt_threads) { + error_report("Cannot support more than %d threads/core " + "on %s machine", max_smt_threads, mc->desc); 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..., @@ -2490,6 +2493,7 @@ static void pnv_machine_power8_class_init(ObjectClass= *oc, void *data) =20 pmc->compat =3D compat; pmc->compat_size =3D sizeof(compat); + pmc->max_smt_threads =3D 8; =20 machine_class_allow_dynamic_sysbus_dev(mc, TYPE_PNV_PHB); } @@ -2514,6 +2518,7 @@ static void pnv_machine_power9_class_init(ObjectClass= *oc, void *data) =20 pmc->compat =3D compat; pmc->compat_size =3D sizeof(compat); + pmc->max_smt_threads =3D 4; pmc->dt_power_mgt =3D pnv_dt_power_mgt; =20 machine_class_allow_dynamic_sysbus_dev(mc, TYPE_PNV_PHB); @@ -2538,6 +2543,7 @@ static void pnv_machine_p10_common_class_init(ObjectC= lass *oc, void *data) =20 pmc->compat =3D compat; pmc->compat_size =3D sizeof(compat); + pmc->max_smt_threads =3D 4; pmc->dt_power_mgt =3D pnv_dt_power_mgt; =20 xfc->match_nvt =3D pnv10_xive_match_nvt; --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147329; cv=none; d=zohomail.com; s=zohoarc; b=ao6rmqlWiNKGHarO+6y7ck3ofUL8YUt0u1p5gLDHSAGxfRfNRZ7c04Zvfde+M1UI+Kt0cqqS1Zth3hH9USsnWPeOHDKvtPgFyk/7BA3beQgQ+pF/lcaHOo/b4ocAUgao+wvSDyiV5LG98joOsXCIISItUoHoXfECc+EnhRHmXvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147329; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5li3telX6sK1Lhm0cQR+KDeo6fDP+MxgfWC2oPVkLoI=; b=HjlOJQ0heg6HY5sG5UPrDLg7J64WgtgdGX+kXwpeczhgYkhoMRmmHnQTvbaXwBfSxRcWv/d2VfIVX8nnMbcAij4Mzxc7TVxtR0kt2KARfkn2nb84s+hhyw+P+6F9Gbo42VpMlGHcif6DfSf1wC28e9byJDnm2AIQ/Ag9BdUa3Gc= 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 1721147329311508.7692222298807; Tue, 16 Jul 2024 09:28:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2O-0002M2-CT; Tue, 16 Jul 2024 12:28:24 -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 1sTl1A-0006Nz-4h; Tue, 16 Jul 2024 12:27:12 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl0s-0006QR-Q6; Tue, 16 Jul 2024 12:27:07 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-7515437ff16so4135853a12.2; Tue, 16 Jul 2024 09:26:49 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:26:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147208; x=1721752008; darn=nongnu.org; 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=5li3telX6sK1Lhm0cQR+KDeo6fDP+MxgfWC2oPVkLoI=; b=CzLo5DuTcZ0N5dnLm1Wp78weKlNQAnOgZTjMa+fUHai/rgxKt58NuZX574AvNFoDdK F1kfy7mq1n9WZs1VUhwh7AmHO6w9alVX6BHUS3yhpJTfmMnuH/iic61Tk6KTFyhg6h/U UIIIAgSFRIbKmv3B9KoNcdnngvYVIVOIZgZkYtIOKN2/a80yNzZNyAhYZ7DVPvkDoFEM zVaTQHeKiK/VCgB9GzFvovtGhkdFJKYoJ97jvLYGbwinX4HUNbRN3SjvhqbCkHnHNuCM hOmjlkJIiuDivoheL2Pl5pIc88LBGTnkoY3LIAfgHrInS5pQ8uLiiNDXPUXnaAodt4ua 9JFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147208; x=1721752008; 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=5li3telX6sK1Lhm0cQR+KDeo6fDP+MxgfWC2oPVkLoI=; b=ZR9rGif2VI8Sci+d7+vkspMMqz/OVvv0tLvaMJIa6fp+g49a3ztE09/zMeYQBfaUFR N5IfiATGWpDnyrrw4rKjXi2ToljGZ5aTM0SrBaTUbwad/l0m2v1+eBXyoJj1gHDLuz5q hfkBIssErqULGy4q832B5a5tfLSnjNnKtxtiuXB8Xn9LxTliHV1uePUmR67AwFAZwVbo kOHllUke40CeKJD4UwcUb6bLdjPHC5yacrRjuLcUVeGQVKoM0XsmiHtcZ7ZBCWurP5ZU irUH7q/573WPjl8TMYl2/W+uYdAJijrXwUqhOrW69DdlXI0rMl5tHwVONkItSGKnyHJ7 oQ7A== X-Forwarded-Encrypted: i=1; AJvYcCUt+RugyDZQmJDcRsgpRHVpG/pN2fARO10AkFyXZlyp79uFCWFg/yyJeMOhaIsFxTfOHvb9qSg1zh+UGdjLCs9eYoRnOdA= X-Gm-Message-State: AOJu0YykcSF/LQcP8uLI6E+F2GXkoBwDLthKF5Jg+S+bNguYd4yzGxVT PN3BJUVjLHjtZGuUznhSR1xZz3DFoH1cJbl29rHAc1qf3t8QmtUbNC/Xxw== X-Google-Smtp-Source: AGHT+IGCPdrY7YUnVOA5GmUnxRqNFR+9j6cQcBjOlkpyKLcw4p1vKTpsqlg1/0ljRK5waBRHBEjdNA== X-Received: by 2002:a05:6a20:3946:b0:1c3:7405:80d0 with SMTP id adf61e73a8af0-1c3f1211cfdmr3284521637.18.1721147208306; Tue, 16 Jul 2024 09:26:48 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v3 06/19] ppc/pnv: Extend chip_pir class method to TIR as well Date: Wed, 17 Jul 2024 02:26:02 +1000 Message-ID: <20240716162617.32161-7-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::530; envelope-from=npiggin@gmail.com; helo=mail-pg1-x530.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 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: 1721147330653116600 The chip_pir chip class method allows the platform to set the PIR processor identification register. Extend this to a more general ID function which also allows the TIR to be set. This is in preparation for "big core", which is a more complicated topology of cores and threads. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv_chip.h | 4 +- hw/ppc/pnv.c | 85 +++++++++++++++++++++++++-------------- hw/ppc/pnv_core.c | 10 +++-- 3 files changed, 64 insertions(+), 35 deletions(-) diff --git a/include/hw/ppc/pnv_chip.h b/include/hw/ppc/pnv_chip.h index 4eaa7d3999..7d5d08bcdc 100644 --- a/include/hw/ppc/pnv_chip.h +++ b/include/hw/ppc/pnv_chip.h @@ -150,7 +150,9 @@ struct PnvChipClass { =20 DeviceRealize parent_realize; =20 - uint32_t (*chip_pir)(PnvChip *chip, uint32_t core_id, uint32_t thread_= id); + /* Get PIR and TIR values for a CPU thread identified by core/thread i= d */ + void (*get_pir_tir)(PnvChip *chip, uint32_t core_id, uint32_t thread_i= d, + uint32_t *pir, uint32_t *tir); void (*intc_create)(PnvChip *chip, PowerPCCPU *cpu, Error **errp); void (*intc_reset)(PnvChip *chip, PowerPCCPU *cpu); void (*intc_destroy)(PnvChip *chip, PowerPCCPU *cpu); diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index fde51ca946..eee34ca926 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -154,7 +154,7 @@ static int pnv_dt_core(PnvChip *chip, PnvCore *pc, void= *fdt) char *nodename; int cpus_offset =3D get_cpus_node(fdt); =20 - pir =3D pnv_cc->chip_pir(chip, pc->hwid, 0); + pnv_cc->get_pir_tir(chip, pc->hwid, 0, &pir, NULL); =20 nodename =3D g_strdup_printf("%s@%x", dc->fw_name, pir); offset =3D fdt_add_subnode(fdt, cpus_offset, nodename); @@ -236,7 +236,8 @@ static int pnv_dt_core(PnvChip *chip, PnvCore *pc, void= *fdt) =20 /* Build interrupt servers properties */ for (i =3D 0; i < smt_threads; i++) { - servers_prop[i] =3D cpu_to_be32(pnv_cc->chip_pir(chip, pc->hwid, i= )); + pnv_cc->get_pir_tir(chip, pc->hwid, i, &pir, NULL); + servers_prop[i] =3D cpu_to_be32(pir); } _FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", servers_prop, sizeof(*servers_prop) * smt_threads))= ); @@ -248,14 +249,17 @@ static void pnv_dt_icp(PnvChip *chip, void *fdt, uint= 32_t hwid, uint32_t nr_threads) { PnvChipClass *pcc =3D PNV_CHIP_GET_CLASS(chip); - uint32_t pir =3D pcc->chip_pir(chip, hwid, 0); - uint64_t addr =3D PNV_ICP_BASE(chip) | (pir << 12); + uint32_t pir; + uint64_t addr; char *name; const char compat[] =3D "IBM,power8-icp\0IBM,ppc-xicp"; uint32_t irange[2], i, rsize; uint64_t *reg; int offset; =20 + pcc->get_pir_tir(chip, hwid, 0, &pir, NULL); + addr =3D PNV_ICP_BASE(chip) | (pir << 12); + irange[0] =3D cpu_to_be32(pir); irange[1] =3D cpu_to_be32(nr_threads); =20 @@ -1106,10 +1110,16 @@ static void pnv_init(MachineState *machine) * 25:28 Core number * 29:31 Thread ID */ -static uint32_t pnv_chip_pir_p8(PnvChip *chip, uint32_t core_id, - uint32_t thread_id) +static void pnv_get_pir_tir_p8(PnvChip *chip, + uint32_t core_id, uint32_t thread_id, + uint32_t *pir, uint32_t *tir) { - return (chip->chip_id << 7) | (core_id << 3) | thread_id; + if (pir) { + *pir =3D (chip->chip_id << 7) | (core_id << 3) | thread_id; + } + if (tir) { + *tir =3D thread_id; + } } =20 static void pnv_chip_power8_intc_create(PnvChip *chip, PowerPCCPU *cpu, @@ -1161,14 +1171,20 @@ static void pnv_chip_power8_intc_print_info(PnvChip= *chip, PowerPCCPU *cpu, * * We only care about the lower bits. uint32_t is fine for the moment. */ -static uint32_t pnv_chip_pir_p9(PnvChip *chip, uint32_t core_id, - uint32_t thread_id) -{ - if (chip->nr_threads =3D=3D 8) { - return (chip->chip_id << 8) | ((thread_id & 1) << 2) | (core_id <<= 3) | - (thread_id >> 1); - } else { - return (chip->chip_id << 8) | (core_id << 2) | thread_id; +static void pnv_get_pir_tir_p9(PnvChip *chip, + uint32_t core_id, uint32_t thread_id, + uint32_t *pir, uint32_t *tir) +{ + if (pir) { + if (chip->nr_threads =3D=3D 8) { + *pir =3D (chip->chip_id << 8) | ((thread_id & 1) << 2) | + (core_id << 3) | (thread_id >> 1); + } else { + *pir =3D (chip->chip_id << 8) | (core_id << 2) | thread_id; + } + } + if (tir) { + *tir =3D thread_id; } } =20 @@ -1183,14 +1199,20 @@ static uint32_t pnv_chip_pir_p9(PnvChip *chip, uint= 32_t core_id, * * We only care about the lower bits. uint32_t is fine for the moment. */ -static uint32_t pnv_chip_pir_p10(PnvChip *chip, uint32_t core_id, - uint32_t thread_id) -{ - if (chip->nr_threads =3D=3D 8) { - return (chip->chip_id << 8) | ((core_id / 4) << 4) | - ((core_id % 2) << 3) | thread_id; - } else { - return (chip->chip_id << 8) | (core_id << 2) | thread_id; +static void pnv_get_pir_tir_p10(PnvChip *chip, + uint32_t core_id, uint32_t thread_id, + uint32_t *pir, uint32_t *tir) +{ + if (pir) { + if (chip->nr_threads =3D=3D 8) { + *pir =3D (chip->chip_id << 8) | ((core_id / 4) << 4) | + ((core_id % 2) << 3) | thread_id; + } else { + *pir =3D (chip->chip_id << 8) | (core_id << 2) | thread_id; + } + } + if (tir) { + *tir =3D thread_id; } } =20 @@ -1370,8 +1392,11 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Er= ror **errp) int core_hwid =3D CPU_CORE(pnv_core)->core_id; =20 for (j =3D 0; j < CPU_CORE(pnv_core)->nr_threads; j++) { - uint32_t pir =3D pcc->chip_pir(chip, core_hwid, j); - PnvICPState *icp =3D PNV_ICP(xics_icp_get(chip8->xics, pir)); + uint32_t pir; + PnvICPState *icp; + + pcc->get_pir_tir(chip, core_hwid, j, &pir, NULL); + icp =3D PNV_ICP(xics_icp_get(chip8->xics, pir)); =20 memory_region_add_subregion(&chip8->icp_mmio, pir << 12, &icp->mmio); @@ -1483,7 +1508,7 @@ static void pnv_chip_power8e_class_init(ObjectClass *= klass, void *data) k->chip_cfam_id =3D 0x221ef04980000000ull; /* P8 Murano DD2.1 */ k->cores_mask =3D POWER8E_CORE_MASK; k->num_phbs =3D 3; - k->chip_pir =3D pnv_chip_pir_p8; + k->get_pir_tir =3D pnv_get_pir_tir_p8; k->intc_create =3D pnv_chip_power8_intc_create; k->intc_reset =3D pnv_chip_power8_intc_reset; k->intc_destroy =3D pnv_chip_power8_intc_destroy; @@ -1507,7 +1532,7 @@ static void pnv_chip_power8_class_init(ObjectClass *k= lass, void *data) k->chip_cfam_id =3D 0x220ea04980000000ull; /* P8 Venice DD2.0 */ k->cores_mask =3D POWER8_CORE_MASK; k->num_phbs =3D 3; - k->chip_pir =3D pnv_chip_pir_p8; + k->get_pir_tir =3D pnv_get_pir_tir_p8; k->intc_create =3D pnv_chip_power8_intc_create; k->intc_reset =3D pnv_chip_power8_intc_reset; k->intc_destroy =3D pnv_chip_power8_intc_destroy; @@ -1531,7 +1556,7 @@ static void pnv_chip_power8nvl_class_init(ObjectClass= *klass, void *data) k->chip_cfam_id =3D 0x120d304980000000ull; /* P8 Naples DD1.0 */ k->cores_mask =3D POWER8_CORE_MASK; k->num_phbs =3D 4; - k->chip_pir =3D pnv_chip_pir_p8; + k->get_pir_tir =3D pnv_get_pir_tir_p8; k->intc_create =3D pnv_chip_power8_intc_create; k->intc_reset =3D pnv_chip_power8_intc_reset; k->intc_destroy =3D pnv_chip_power8_intc_destroy; @@ -1814,7 +1839,7 @@ static void pnv_chip_power9_class_init(ObjectClass *k= lass, void *data) =20 k->chip_cfam_id =3D 0x220d104900008000ull; /* P9 Nimbus DD2.0 */ k->cores_mask =3D POWER9_CORE_MASK; - k->chip_pir =3D pnv_chip_pir_p9; + k->get_pir_tir =3D pnv_get_pir_tir_p9; k->intc_create =3D pnv_chip_power9_intc_create; k->intc_reset =3D pnv_chip_power9_intc_reset; k->intc_destroy =3D pnv_chip_power9_intc_destroy; @@ -2136,7 +2161,7 @@ static void pnv_chip_power10_class_init(ObjectClass *= klass, void *data) =20 k->chip_cfam_id =3D 0x120da04900008000ull; /* P10 DD1.0 (with NX) */ k->cores_mask =3D POWER10_CORE_MASK; - k->chip_pir =3D pnv_chip_pir_p10; + k->get_pir_tir =3D pnv_get_pir_tir_p10; k->intc_create =3D pnv_chip_power10_intc_create; k->intc_reset =3D pnv_chip_power10_intc_reset; k->intc_destroy =3D pnv_chip_power10_intc_destroy; diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 2da271ffb6..28ca61926d 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -227,8 +227,9 @@ static void pnv_core_cpu_realize(PnvCore *pc, PowerPCCP= U *cpu, Error **errp, { CPUPPCState *env =3D &cpu->env; int core_hwid; - ppc_spr_t *pir =3D &env->spr_cb[SPR_PIR]; - ppc_spr_t *tir =3D &env->spr_cb[SPR_TIR]; + ppc_spr_t *pir_spr =3D &env->spr_cb[SPR_PIR]; + ppc_spr_t *tir_spr =3D &env->spr_cb[SPR_TIR]; + uint32_t pir, tir; Error *local_err =3D NULL; PnvChipClass *pcc =3D PNV_CHIP_GET_CLASS(pc->chip); =20 @@ -244,8 +245,9 @@ static void pnv_core_cpu_realize(PnvCore *pc, PowerPCCP= U *cpu, Error **errp, =20 core_hwid =3D object_property_get_uint(OBJECT(pc), "hwid", &error_abor= t); =20 - tir->default_value =3D thread_index; - pir->default_value =3D pcc->chip_pir(pc->chip, core_hwid, thread_index= ); + pcc->get_pir_tir(pc->chip, core_hwid, thread_index, &pir, &tir); + pir_spr->default_value =3D pir; + tir_spr->default_value =3D tir; =20 /* Set time-base frequency to 512 MHz */ cpu_ppc_tb_init(env, PNV_TIMEBASE_FREQ); --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147480; cv=none; d=zohomail.com; s=zohoarc; b=C2DxieJQNF4KVMDFcsmwriVjzLlaKKzm93BchoP+on/rPK5pQsFhLgullmhcQjBI0Xlwstga3c0vM51IiY+Txff2rYYws0OCUDEf646Hz4DaV4aj23Y/tQQ5s7OfzI3VyVCVm4YXvK1nbTppzh0PhaMy88PQWWTEs0L3LjOrv/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147480; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sqrzDK8wkTq/L5krI5RVW4u/qudiQvRHJA8S9u6V2LU=; b=hy9poYKXt+Xt5VNF7tHfVLnQORrKRwnvecm9L2vyjCanDvHfehqJwgwQBoPGNZ8nRSLNtTVOzEJfYelbXCnssZI2o/9DAS09eEk50CxigNE7CCTOJUVY/BZcmMRCS9wMfQrurlVOEH6Cq4SGBQrN9wVE8L+XptrwEuTFt3fVAz0= 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 172114748078071.20295447338765; Tue, 16 Jul 2024 09:31:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2W-0003zu-QN; Tue, 16 Jul 2024 12:28:32 -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 1sTl19-0006Ny-UK; Tue, 16 Jul 2024 12:27:12 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl0y-0006SI-KX; Tue, 16 Jul 2024 12:27:05 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-70af8062039so3930527b3a.0; Tue, 16 Jul 2024 09:26:53 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.26.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147212; x=1721752012; darn=nongnu.org; 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=sqrzDK8wkTq/L5krI5RVW4u/qudiQvRHJA8S9u6V2LU=; b=ThpYeH9/hFZq+GU+9ZaudGHCkyEKmkrHF/I8G1vhG2cGD+l9HJ7EnIKEM3BLaXwQtl GZlQxbsFCqaJ1qRG9fYawUpv1OCIoVZ0ZyHpZhK1iIkFvJ2TnPwzPdmgUJSkyE98FYeO +6aPaVO4ehm9OKIjFrw92kMoRDkDFVqovfc+v1N2eaqTnFfiVUTHsm1NrZpllZAR8L6A Y/+ggEgLm4QaBPD5Ca6OQpFjB9eapavoBYfou8tu7PcZrsRQChbg7Mi2bqYc3MKu1zmN fh36hjndhRp235Kh/Nm6+zAEJTWMGWvL44xQFkJ6prPXb7puWQfR/SgX7tHzWYAmCI2T fEDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147212; x=1721752012; 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=sqrzDK8wkTq/L5krI5RVW4u/qudiQvRHJA8S9u6V2LU=; b=QbDPVb04J1RjZrKelfBiSN6AZZ0Y8ojqdWqVsOVW7KnXTeed79PCEf8JRZ7JUe8R8O EGJfOagjFrIRywaWxy2gToiodKXvPETYi9vD520fs2Y+lvMEf5RyVwhxAtJjWD/Ez2Dr gWpGhN/m+MT5lsLRApS1Kg0AzvUh0ujG0CyHtSJySmolDnDU8qzHNn72RyVxk75pUCsD WowpExKzSuBaNDNjsglKKDX9ei1nFr4UyWTF9RysOsek3J4GbUAB8nSevP50EKqLIiqm GDNfoRdvmZLoCH+67nbRZXWgBjX4IyY5XVaj5WDUIn6Ywq6hF+wIX6PXhWlL/83HrUOZ Bo5g== X-Forwarded-Encrypted: i=1; AJvYcCWu61+HmSZIG5LT67t73Bn1R+xaapRf2KM8cee2bAnOauDPTs9cxSBhxzJqUZFHiNN7HGRk11Ett/H+v9Qkayz3JygSQHA= X-Gm-Message-State: AOJu0YwMkuEFQNAatdLUrUvNLHrbnMiyf7Q8MkM49Fb7feHMQL6terB7 2bvih2xA3B/EZ+4w7HtiJ8XjknSihIrp//h09x0ztbQDrGtper87PoVfqQ== X-Google-Smtp-Source: AGHT+IG7Nki7IW/0NrKWMXHwmqbes6tmbvplh5ZZw19RVHFjBW6x12Zb7jSYUtN1Tzb+oJBt23IC5Q== X-Received: by 2002:a05:6a00:1950:b0:705:9b04:71b with SMTP id d2e1a72fcca58-70c2ea27abfmr2976192b3a.31.1721147212194; Tue, 16 Jul 2024 09:26:52 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v3 07/19] ppc: Add a core_index to CPUPPCState for SMT vCPUs Date: Wed, 17 Jul 2024 02:26:03 +1000 Message-ID: <20240716162617.32161-8-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::42c; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42c.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 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: 1721147481328116600 The way SMT thread siblings are matched is clunky, using hard-coded logic that checks the PIR SPR. Change that to use a new core_index variable in the CPUPPCState, where all siblings have the same core_index. CPU realize routines have flexibility in setting core/sibling topology. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- target/ppc/cpu.h | 9 +++++---- hw/ppc/pnv_core.c | 2 ++ hw/ppc/spapr_cpu_core.c | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 95ba9e7590..7b52a9bb18 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1247,6 +1247,9 @@ struct CPUArchState { /* when a memory exception occurs, the access type is stored here */ int access_type; =20 + /* For SMT processors */ + int core_index; + #if !defined(CONFIG_USER_ONLY) /* MMU context, only relevant for full system emulation */ #if defined(TARGET_PPC64) @@ -1402,12 +1405,10 @@ struct CPUArchState { uint64_t pmu_base_time; }; =20 -#define _CORE_ID(cs) \ - (POWERPC_CPU(cs)->env.spr_cb[SPR_PIR].default_value & ~(cs->nr_threads= - 1)) - #define THREAD_SIBLING_FOREACH(cs, cs_sibling) \ CPU_FOREACH(cs_sibling) \ - if (_CORE_ID(cs) =3D=3D _CORE_ID(cs_sibling)) + if (POWERPC_CPU(cs)->env.core_index =3D=3D \ + POWERPC_CPU(cs_sibling)->env.core_index) =20 #define SET_FIT_PERIOD(a_, b_, c_, d_) \ do { \ diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 28ca61926d..7bda29b9c7 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -249,6 +249,8 @@ static void pnv_core_cpu_realize(PnvCore *pc, PowerPCCP= U *cpu, Error **errp, pir_spr->default_value =3D pir; tir_spr->default_value =3D tir; =20 + env->core_index =3D core_hwid; + /* Set time-base frequency to 512 MHz */ cpu_ppc_tb_init(env, PNV_TIMEBASE_FREQ); } diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 21920ea054..4e13e6993a 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -302,11 +302,13 @@ static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc= , int i, Error **errp) g_autofree char *id =3D NULL; CPUState *cs; PowerPCCPU *cpu; + CPUPPCState *env; =20 obj =3D object_new(scc->cpu_type); =20 cs =3D CPU(obj); cpu =3D POWERPC_CPU(obj); + env =3D &cpu->env; /* * All CPUs start halted. CPU0 is unhalted from the machine level rese= t code * and the rest are explicitly started up by the guest using an RTAS c= all. @@ -317,6 +319,8 @@ static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc, = int i, Error **errp) return NULL; } =20 + env->core_index =3D cc->core_id; + cpu->node_id =3D sc->node_id; =20 id =3D g_strdup_printf("thread[%d]", i); --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147480; cv=none; d=zohomail.com; s=zohoarc; b=HJJ2SXas8IhMZ39xOYrdJ5/AosCNm7IuOIAUAdjZmOlL112pM6Cbd4uscYQvZvNnEvpxy0aRst2LYoTYcv+wbsKQ+1EMymqpOXLXcVSBZkYaK5jS3+vwdTW8yZ1P7VCBBvkw9sn1jTj4OBqIHkZKQMtKLWDjzOSJHzvwvAmxLU8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147480; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=P/jaJY+EjT/k2aXL1glM+yk4w079Fmr/WkbzC5YoxgU=; b=X0C5Botgojew4DYwj/0O2/gGYIYGys3leQkozz8vaRJhmRGdUFL2Ns5O4rCLWjU1x6eQKvM0NqTXR/0Lfqg9ny1Jz4nxYkDxfHn2a+X4bTyIxz/bByc1QjldPfrbc6N2wI1ccQ8BvHm6uVeZRluINEuUr7c/jPOJMFJvzzago8Q= 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 1721147480549691.0176825250157; Tue, 16 Jul 2024 09:31:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2Q-0002mY-H5; Tue, 16 Jul 2024 12:28:26 -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 1sTl1F-0006V6-KT; Tue, 16 Jul 2024 12:27:17 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl1A-0006TI-0N; Tue, 16 Jul 2024 12:27:10 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-70b0d0fefe3so3801992b3a.2; Tue, 16 Jul 2024 09:26:57 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147216; x=1721752016; darn=nongnu.org; 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=P/jaJY+EjT/k2aXL1glM+yk4w079Fmr/WkbzC5YoxgU=; b=RYVIg9MBTk8JoppeoCyfz8yyNctBqeVy2ikaQLcm3RxjOTZ4BvxILMlbFyPIimUytP fPazvoOly+Ljb7xzdYDk0RknEdwODFdGbv4ZBqGLKFIkaACjeEI63w/dVm0swi9SXy5X pmlATUQDGkxl0hW44iT+VORSBkw0CNlDaW1Bpc35yWgwTg9EGbKczEK9lLX2wzNdXOdX p4EGd/fZVKSM9Zyj4Ro1tgROgzDT7SB1p/xkizEvYGbnaRRHRauadaAity12OHqEYz0P ydn9mfMHTIT+7RCi3caVEuP1xuYrVon974k3aU5f6NLWJDrKYMUS/n+leDXs6PVKKFfF fEHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147216; x=1721752016; 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=P/jaJY+EjT/k2aXL1glM+yk4w079Fmr/WkbzC5YoxgU=; b=V/EtW/Vrf1bIPMvQ3HxEk4DDpOz6k4loImwAB+RIqvmzpFrR2P2E+8cdvh6Re5rQ9Y pxKpTaVxFe9taFpdxxB6oN9MG7N9IEVKuoYNJAuIeZRg6b3oIUtg9n9UX6v5rjIbNSQa rJhwxIX5mUqs5+/r4NXDewUhg00iUT96I2HSk6lSeYSl0xjp0lZQrY4gsEZzt6a9nn24 Y+GSZBI6kfFrDzfba97a4EA8MafO9qUvBSwpU1Tbaq5vmvM08g8WFpTFId/RZGZyXqw4 O7wC7dQnzTkYRsBa3FW+3RhifPacZcLe3DKebd6H0Nj/3kpyh0U2m2iPE9XzdqndBUEl oLhQ== X-Forwarded-Encrypted: i=1; AJvYcCX/iGw8bkiuUaAlqPZ9sQmwfFOCBaS4NfZjCFdTZgCVVauXLa/fDrjoVF/HRbtQ2O0YfYC0XUPRiAvXBmLREoF6IWsEIag= X-Gm-Message-State: AOJu0YxigkXMVa6hAfw3xsVQaXhVnXvPu66+KZfZa+29qLelF/jCmxgr BtcBKEhiY+0FOuk26FXCos4HasDKI1DPNEyztkhZqRcX+uidpGACxAU++Q== X-Google-Smtp-Source: AGHT+IFiEEZ1j7C3/LhPSE88tX/K0zT0Bl2AVFxe4IpKxW8/Ty5QAFI2Jt8T8VBlf19/hKHlNPXVpQ== X-Received: by 2002:a05:6a21:3384:b0:1c2:8f4b:503b with SMTP id adf61e73a8af0-1c3f11eb825mr3369001637.11.1721147215765; Tue, 16 Jul 2024 09:26:55 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH v3 08/19] target/ppc: Add helpers to check for SMT sibling threads Date: Wed, 17 Jul 2024 02:26:04 +1000 Message-ID: <20240716162617.32161-9-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::436; envelope-from=npiggin@gmail.com; helo=mail-pf1-x436.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 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: 1721147481381116600 Content-Type: text/plain; charset="utf-8" Add helpers for TCG code to determine if there are SMT siblings sharing per-core and per-lpar registers. This simplifies the callers and makes SMT register topology simpler to modify with later changes. Reviewed-by: Harsh Prateek Bora Signed-off-by: Nicholas Piggin --- target/ppc/cpu.h | 11 +++++++++++ target/ppc/cpu_init.c | 2 +- target/ppc/excp_helper.c | 17 +++++------------ target/ppc/misc_helper.c | 27 ++++++--------------------- target/ppc/timebase_helper.c | 20 +++++++------------- 5 files changed, 30 insertions(+), 47 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 7b52a9bb18..417b284318 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1512,6 +1512,17 @@ struct PowerPCCPUClass { int (*check_attn)(CPUPPCState *env); }; =20 +static inline bool ppc_cpu_core_single_threaded(CPUState *cs) +{ + return cs->nr_threads =3D=3D 1; +} + +static inline bool ppc_cpu_lpar_single_threaded(CPUState *cs) +{ + return !(POWERPC_CPU(cs)->env.flags & POWERPC_FLAG_SMT_1LPAR) || + ppc_cpu_core_single_threaded(cs); +} + ObjectClass *ppc_cpu_class_by_name(const char *name); PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr); PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr); diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 164bb62e63..81dd4e1a7a 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6993,7 +6993,7 @@ static void ppc_cpu_realize(DeviceState *dev, Error *= *errp) =20 pcc->parent_realize(dev, errp); =20 - if (env_cpu(env)->nr_threads > 1) { + if (!ppc_cpu_core_single_threaded(cs)) { env->flags |=3D POWERPC_FLAG_SMT; } =20 diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 5368bf2ff3..5ecd662f9e 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -3014,18 +3014,11 @@ static void msgsnd_core_tir(CPUPPCState *env, uint3= 2_t target_tir, int irq) { PowerPCCPU *cpu =3D env_archcpu(env); CPUState *cs =3D env_cpu(env); - uint32_t nr_threads =3D cs->nr_threads; =20 - if (!(env->flags & POWERPC_FLAG_SMT_1LPAR)) { - nr_threads =3D 1; /* msgsndp behaves as 1-thread in LPAR-per-threa= d mode*/ - } - - if (target_tir >=3D nr_threads) { - return; - } - - if (nr_threads =3D=3D 1) { - ppc_set_irq(cpu, irq, 1); + if (ppc_cpu_lpar_single_threaded(cs)) { + if (target_tir =3D=3D 0) { + ppc_set_irq(cpu, irq, 1); + } } else { CPUState *ccs; =20 @@ -3080,7 +3073,7 @@ void helper_book3s_msgsnd(CPUPPCState *env, target_ul= ong rb) brdcast =3D true; } =20 - if (cs->nr_threads =3D=3D 1 || !brdcast) { + if (ppc_cpu_core_single_threaded(cs) || !brdcast) { ppc_set_irq(cpu, PPC_INTERRUPT_HDOORBELL, 1); return; } diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index 4d3c1bddd9..692e48e6bc 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -49,9 +49,8 @@ void helper_spr_core_write_generic(CPUPPCState *env, uint= 32_t sprn, { CPUState *cs =3D env_cpu(env); CPUState *ccs; - uint32_t nr_threads =3D cs->nr_threads; =20 - if (nr_threads =3D=3D 1) { + if (ppc_cpu_core_single_threaded(cs)) { env->spr[sprn] =3D val; return; } @@ -196,7 +195,7 @@ void helper_store_ptcr(CPUPPCState *env, target_ulong v= al) return; } =20 - if (cs->nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LP= AR)) { + if (ppc_cpu_lpar_single_threaded(cs)) { env->spr[SPR_PTCR] =3D val; tlb_flush(cs); } else { @@ -243,16 +242,12 @@ target_ulong helper_load_dpdes(CPUPPCState *env) { CPUState *cs =3D env_cpu(env); CPUState *ccs; - uint32_t nr_threads =3D cs->nr_threads; target_ulong dpdes =3D 0; =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) { + /* DPDES behaves as 1-thread in LPAR-per-thread mode */ + if (ppc_cpu_lpar_single_threaded(cs)) { if (env->pending_interrupts & PPC_INTERRUPT_DOORBELL) { dpdes =3D 1; } @@ -279,21 +274,11 @@ void helper_store_dpdes(CPUPPCState *env, target_ulon= g val) PowerPCCPU *cpu =3D env_archcpu(env); CPUState *cs =3D env_cpu(env); CPUState *ccs; - uint32_t nr_threads =3D cs->nr_threads; =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); - val &=3D (nr_threads - 1); /* Ignore the invalid bits */ - } - - if (nr_threads =3D=3D 1) { + /* DPDES behaves as 1-thread in LPAR-per-thread mode */ + if (ppc_cpu_lpar_single_threaded(cs)) { ppc_set_irq(cpu, PPC_INTERRUPT_DOORBELL, val & 0x1); return; } diff --git a/target/ppc/timebase_helper.c b/target/ppc/timebase_helper.c index 52f9e6669c..44cacf065e 100644 --- a/target/ppc/timebase_helper.c +++ b/target/ppc/timebase_helper.c @@ -63,9 +63,8 @@ void helper_store_purr(CPUPPCState *env, target_ulong val) { CPUState *cs =3D env_cpu(env); CPUState *ccs; - uint32_t nr_threads =3D cs->nr_threads; =20 - if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + if (ppc_cpu_lpar_single_threaded(cs)) { cpu_ppc_store_purr(env, val); return; } @@ -82,9 +81,8 @@ void helper_store_tbl(CPUPPCState *env, target_ulong val) { CPUState *cs =3D env_cpu(env); CPUState *ccs; - uint32_t nr_threads =3D cs->nr_threads; =20 - if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + if (ppc_cpu_lpar_single_threaded(cs)) { cpu_ppc_store_tbl(env, val); return; } @@ -99,9 +97,8 @@ void helper_store_tbu(CPUPPCState *env, target_ulong val) { CPUState *cs =3D env_cpu(env); CPUState *ccs; - uint32_t nr_threads =3D cs->nr_threads; =20 - if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + if (ppc_cpu_lpar_single_threaded(cs)) { cpu_ppc_store_tbu(env, val); return; } @@ -141,9 +138,8 @@ void helper_store_hdecr(CPUPPCState *env, target_ulong = val) { CPUState *cs =3D env_cpu(env); CPUState *ccs; - uint32_t nr_threads =3D cs->nr_threads; =20 - if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + if (ppc_cpu_lpar_single_threaded(cs)) { cpu_ppc_store_hdecr(env, val); return; } @@ -158,9 +154,8 @@ void helper_store_vtb(CPUPPCState *env, target_ulong va= l) { CPUState *cs =3D env_cpu(env); CPUState *ccs; - uint32_t nr_threads =3D cs->nr_threads; =20 - if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + if (ppc_cpu_lpar_single_threaded(cs)) { cpu_ppc_store_vtb(env, val); return; } @@ -175,9 +170,8 @@ void helper_store_tbu40(CPUPPCState *env, target_ulong = val) { CPUState *cs =3D env_cpu(env); CPUState *ccs; - uint32_t nr_threads =3D cs->nr_threads; =20 - if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + if (ppc_cpu_lpar_single_threaded(cs)) { cpu_ppc_store_tbu40(env, val); return; } @@ -288,7 +282,7 @@ static void write_tfmr(CPUPPCState *env, target_ulong v= al) { CPUState *cs =3D env_cpu(env); =20 - if (cs->nr_threads =3D=3D 1) { + if (ppc_cpu_core_single_threaded(cs)) { env->spr[SPR_TFMR] =3D val; } else { CPUState *ccs; --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147321; cv=none; d=zohomail.com; s=zohoarc; b=HL90O653JhOr+kuK5vIO/EFeEcDVCSdK/kti24KSgqh48K6A2RTFMJtY/CswhpwixiAzuK4nKDcd/mO99zlDaCECiGXxn81/fUy4Vx8fL0qzwX8uhq1vQZqF/I5lfMS3tqzkTYrm6+kTuKYA9PE484Tz016f/Pv9DL+/0aFPqX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147321; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nwGrMKj4cs0jZjJ7yD0GR8qpP2HCKrG9RQwqRirqlHE=; b=ep4RRatxukHVWMn43lyT1hb5nuDUdbbxDbBibsxAGSRhVSSp/sH3IW8TPNMQRSuGm/oertxWJxzAaBuFiOd4V7NSV0bZs5NEIkpeOcEYmehgqpn1y93S4Xzv2ByAmJOlIkxVeGKJ5tC+8EiaDu6E83dqBWxlJpdL6AU77JOAEmY= 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 1721147321525640.6810934278045; Tue, 16 Jul 2024 09:28:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl1x-0008K3-R8; Tue, 16 Jul 2024 12:27:59 -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 1sTl1B-0006O2-AV; Tue, 16 Jul 2024 12:27:13 -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 1sTl19-0006TQ-3c; Tue, 16 Jul 2024 12:27:09 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-70af22a9c19so4260667b3a.2; Tue, 16 Jul 2024 09:27:00 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147219; x=1721752019; darn=nongnu.org; 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=nwGrMKj4cs0jZjJ7yD0GR8qpP2HCKrG9RQwqRirqlHE=; b=GaYg8BfnUlDKq3PoowXHhYxxqjsmxk0DUP0YOg8QRfpUfTatRbePzrofIc8OS3QKFA posy5u50xPfaZQzPiMDTFEfA5BTsyyiQVMu5aUjcIn10kxlhaudUWseFkfHWKPE7tKDf DqgIAssMR0AWYdo4twr1yPf1HDSlHqnf+mTTU3gcSn5wwkzQFlNIL2wGc7CLdvVujzdU 7L6/qBa6WhvXMjEltFZqoL8tKnXJNY5OMDhBU09ZH7cHqTtT/kGpFHk8rDNFtuEk/lPt fwf/XqxTCyWTEgFRf4HXgcXCMXp7Hf7/lXxNFGlKgssf5N5DI1mTw0CkY7X4pohbAfx1 n/Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147219; x=1721752019; 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=nwGrMKj4cs0jZjJ7yD0GR8qpP2HCKrG9RQwqRirqlHE=; b=ptq8Lgjnr3uWju4v1h3nyrt8+g+cUOMf1lvivXB4hw12jbS5fvbEByUpy2xBFq6XhI a9/SxVg2B/SCYUX/WmeRJnxrkwHoS1j4iVbnPV1AkFyu9eXVcN5Sac5fnKpSHgGXJ+j+ gXghuUl14/gRn0ZYqx4krKmWj5jtKktAOq/6WVylmAF+TgAH/9hqFCyek9hTxPu5TMGj dRf/JhYhRM8D0r8B7pHP2N665Q5k0GluZZ0FnMTsbGLhi+AsAqbfCtOY4jaFhvUqdmaa c1F+uM/bFjoe5852XX/rhOk4zq796Omm9EacJ1e2j6fCyCFFePgtRQUqZPIKB2pgAxbU imRg== X-Forwarded-Encrypted: i=1; AJvYcCVNNDnN9ccDMLGofb3MVptFkeB6PgVnoFGa/SeGNKyYnS+aIEzQ8jjnbhpAWwTgymm2wscrIoqG/1hXQdUtL41nvDKkDTg= X-Gm-Message-State: AOJu0Yy+pwHEVfhfZIz/fC9jFJoFWCdSMh8bamUA3PN52zpha7EZy1KL P8yjs/NVVmPkk7M7gvBsMmM6qcHcXKgeJxccqzBj+IRRPeM/6mFPDAV3FA== X-Google-Smtp-Source: AGHT+IFkxxBoA2u1gV74km9hiM18CYwTzj7RxM8usCgNp3pXrhazc1g3zHYkfP9kNdyREmi7aIRH5g== X-Received: by 2002:a05:6a00:a1a:b0:705:a7a6:6d11 with SMTP id d2e1a72fcca58-70c2e9b4b50mr3401535b3a.24.1721147219452; Tue, 16 Jul 2024 09:26:59 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v3 09/19] ppc: Add has_smt_siblings property to CPUPPCState Date: Wed, 17 Jul 2024 02:26:05 +1000 Message-ID: <20240716162617.32161-10-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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 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: 1721147322591116600 The decision to branch out to a slower SMT path in instruction emulation will become a bit more complicated with the way that "big-core" topology that will be implemented in subsequent changes. Hide these details from the wider CPU emulation code with a bool has_smt_siblings flag that can be set by machine initialisation. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- target/ppc/cpu.h | 3 ++- hw/ppc/pnv_core.c | 3 +++ hw/ppc/spapr_cpu_core.c | 12 +++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 417b284318..321ed2da75 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1248,6 +1248,7 @@ struct CPUArchState { int access_type; =20 /* For SMT processors */ + bool has_smt_siblings; int core_index; =20 #if !defined(CONFIG_USER_ONLY) @@ -1514,7 +1515,7 @@ struct PowerPCCPUClass { =20 static inline bool ppc_cpu_core_single_threaded(CPUState *cs) { - return cs->nr_threads =3D=3D 1; + return !POWERPC_CPU(cs)->env.has_smt_siblings; } =20 static inline bool ppc_cpu_lpar_single_threaded(CPUState *cs) diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 7bda29b9c7..8cfa94fbfa 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -288,6 +288,9 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) cpu =3D POWERPC_CPU(obj); =20 pc->threads[i] =3D POWERPC_CPU(obj); + if (cc->nr_threads > 1) { + cpu->env.has_smt_siblings =3D true; + } =20 snprintf(name, sizeof(name), "thread[%d]", i); object_property_add_child(OBJECT(pc), name, obj); diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 4e13e6993a..2c6eeb41a4 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -351,9 +351,15 @@ static void spapr_cpu_core_realize(DeviceState *dev, E= rror **errp) qemu_register_reset(spapr_cpu_core_reset_handler, sc); sc->threads =3D g_new0(PowerPCCPU *, cc->nr_threads); for (i =3D 0; i < cc->nr_threads; i++) { - sc->threads[i] =3D spapr_create_vcpu(sc, i, errp); - if (!sc->threads[i] || - !spapr_realize_vcpu(sc->threads[i], spapr, sc, i, errp)) { + PowerPCCPU *cpu; + + cpu =3D spapr_create_vcpu(sc, i, errp); + sc->threads[i] =3D cpu; + if (cpu && cc->nr_threads > 1) { + cpu->env.has_smt_siblings =3D true; + } + + if (!cpu || !spapr_realize_vcpu(cpu, spapr, sc, i, errp)) { spapr_cpu_core_unrealize(dev); return; } --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147324; cv=none; d=zohomail.com; s=zohoarc; b=VmCbvM/R+PvepLXnq24CwkMax0OM/RgLo71YyggBft2KE97WDIJbd3IE0sw+4yoSjlPwug1CrL+MTnDPUxcm44IVV63vPjiRLNApP0HpIKyxTUsqLIrU+Fdw3J/Fabe5H3Gm8dQMBgAdm6vC6bIZAGEy/LuSZXI9IkcikJcJXvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147324; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Z2WZMohObGeDSAqehCGzt7eT5JqWsK9VYJvFmu0NkFE=; b=CSFXJDw+EChNxPAxgOJLmP4HQ9wIalc3LNYvGWvt0VFqkltU0YqMcE5FnQx/JDoqeTnWTCOTm06eDurpnQeWWkNQMQSvaJ7cV4b/AfU6h5WAKmfgkgYuneonDvIKDigOOznTcJs0MXrHooA/9NEhdzCWw5h1Lo3yfgheG8S6zFA= 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 172114732473217.82186798381815; Tue, 16 Jul 2024 09:28:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2P-0002J7-B0; Tue, 16 Jul 2024 12:28:25 -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 1sTl1F-0006V5-KH; Tue, 16 Jul 2024 12:27:17 -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 1sTl1A-0006WV-1f; Tue, 16 Jul 2024 12:27:10 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-70af8128081so3885119b3a.1; Tue, 16 Jul 2024 09:27:04 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147223; x=1721752023; darn=nongnu.org; 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=Z2WZMohObGeDSAqehCGzt7eT5JqWsK9VYJvFmu0NkFE=; b=MDM0WPhxDLS63STlovLvVrFHaM6LgMXnFUib7sPDYdZDnqTOiiDaJx7y8Dv5HQbfEY 67SKDctHMvr755IFo+0cr8a8X9Y0/YQekc3/eYJCewSfFgCm6F2rW60onyj6Wt1HH9gY ZQ8bJ2oZKecn+av0Py0zvbUhWxJSJHWv25PuTyv0I+v+BWmkVtE+Fd3ldvms1EKFUCxJ iu4OMYUWaJFtDG4rBUsakGd0FhXrltpb03n+JsK33Zt7BKsNpH1B9ubhEBQZ7Qn8RIea m3vYYhwD5ThYfA0ZMaQn+QznTPp3wMunfA6LL766OR9kHcSrwxiP1eSbQQCmUM86Xstt xZnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147223; x=1721752023; 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=Z2WZMohObGeDSAqehCGzt7eT5JqWsK9VYJvFmu0NkFE=; b=NxrnMZgx54lFgIb2qP25PUN9QDo6ITmSVFwg04ZZQP4JIk6k6YysN2mFaKfabkm5KU 9lQqFw34es4MVIOF1vm7s++41eR/cj8m6kpxtV0zq619smhTzSerl1Hpd+RAKlsz++Xe phGtgAc4VagQu75PBeO1/bdKM8QDTtvZ/3Iy+w78GEVUl953InQ3/D9VA0Vvrc5CW0dY FyBE0TO/bf3YngPN7C/Csmt3dwwHkSg+8YddhknpnM2Pb6tw5QfkdRD2hG9o7m+WPBmC qORmWToalFECaqRNE6zO3S68MxHinoohaQNoCbkQnkNk6SqQ6f12ltdPMldYTCP8BUtZ Uv7Q== X-Forwarded-Encrypted: i=1; AJvYcCUvdnzqjdu3pLyydkNXhYw4XKVJfpr0PTfhcvGZUapGiCAs8gvQ5SGjUPs8sViKHdXxKFnPtqrVpSnhlE0gPuT3QXO9R9c= X-Gm-Message-State: AOJu0YzUpgbC7b7p72vmJ+Jcncu1SM1noNUN6PL9xbT84cbpiUJfnaO+ pfqGQXRf640jzT7r3C0YaOQSklgkMumITodbid/WbWUNVUbijZ+8SKeDQg== X-Google-Smtp-Source: AGHT+IH6RRHSntN7spo7FOEur483LC6RDgdAPvfD/gWl92jx0FjY58XHXHERBXhq7m9lDhp2b+FCFw== X-Received: by 2002:a05:6a21:3213:b0:1c0:bf35:ef4c with SMTP id adf61e73a8af0-1c3f11f1618mr3025033637.11.1721147223054; Tue, 16 Jul 2024 09:27:03 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH v3 10/19] ppc/pnv: Add a big-core mode that joins two regular cores Date: Wed, 17 Jul 2024 02:26:06 +1000 Message-ID: <20240716162617.32161-11-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::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 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: 1721147326656116600 Content-Type: text/plain; charset="utf-8" POWER9 and POWER10 machines come in two variants, big-core and small-core. Big-core machines are SMT8 from software's point of view, but the low level platform topology ("xscom registers and pervasive addressing"), these look more like a pair of small cores ganged together. Presently the way this is modelled is to create one SMT8 PnvCore and add special cases to xscom and pervasive for big-core mode that tries to split this into two small cores, but this is becoming too complicated to manage. A better approach is to create 2 core structures and ganging them together to look like an SMT8 core in TCG. Then the xscom and pervasive models mostly do not need to differentiate big and small core modes. This change adds initial mode bits and QEMU topology handling to split SMT8 cores into 2xSMT4 cores. Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv.h | 2 + include/hw/ppc/pnv_chip.h | 1 + include/hw/ppc/pnv_core.h | 1 + hw/ppc/pnv.c | 80 ++++++++++++++++++++++++++++++++------- hw/ppc/pnv_core.c | 8 +++- 5 files changed, 78 insertions(+), 14 deletions(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 1993dededf..283ddd50e7 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -101,6 +101,8 @@ struct PnvMachineState { PnvPnor *pnor; =20 hwaddr fw_load_addr; + + bool big_core; }; =20 PnvChip *pnv_get_chip(PnvMachineState *pnv, uint32_t chip_id); diff --git a/include/hw/ppc/pnv_chip.h b/include/hw/ppc/pnv_chip.h index 7d5d08bcdc..69d8273efe 100644 --- a/include/hw/ppc/pnv_chip.h +++ b/include/hw/ppc/pnv_chip.h @@ -27,6 +27,7 @@ struct PnvChip { uint64_t ram_start; uint64_t ram_size; =20 + bool big_core; uint32_t nr_cores; uint32_t nr_threads; uint64_t cores_mask; diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h index 693acb189b..50164e9e1f 100644 --- a/include/hw/ppc/pnv_core.h +++ b/include/hw/ppc/pnv_core.h @@ -49,6 +49,7 @@ struct PnvCore { =20 /*< public >*/ PowerPCCPU **threads; + bool big_core; uint32_t pir; uint32_t hwid; uint64_t hrmor; diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index eee34ca926..d902860ecd 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1002,14 +1002,39 @@ static void pnv_init(MachineState *machine) pnv->num_chips =3D machine->smp.max_cpus / (machine->smp.cores * machine->smp.threads= ); =20 + if (pnv->big_core) { + if (machine->smp.threads % 2 =3D=3D 1) { + error_report("Cannot support %d threads with big-core option " + "because it must be an even number", + machine->smp.threads); + exit(1); + } + max_smt_threads *=3D 2; + } + if (machine->smp.threads > max_smt_threads) { error_report("Cannot support more than %d threads/core " "on %s machine", max_smt_threads, mc->desc); + if (pmc->max_smt_threads =3D=3D 4) { + error_report("(use big-core=3Don for 8 threads per core)"); + } exit(1); } =20 + if (pnv->big_core) { + /* + * powernv models PnvCore as a SMT4 core. Big-core requires 2xPnvC= ore + * per core, so adjust topology here. pnv_dt_core() processor + * device-tree and TCG SMT code make the 2 cores appear as one big= core + * from software point of view. pnv pervasive models and xscoms te= nd to + * see the big core as 2 small core halves. + */ + machine->smp.cores *=3D 2; + machine->smp.threads /=3D 2; + } + if (!is_power_of_2(machine->smp.threads)) { - error_report("Cannot support %d threads/core on a powernv" + error_report("Cannot support %d threads/core on a powernv " "machine because it must be a power of 2", machine->smp.threads); exit(1); @@ -1048,6 +1073,8 @@ static void pnv_init(MachineState *machine) &error_fatal); object_property_set_int(chip, "nr-threads", machine->smp.threads, &error_fatal); + object_property_set_bool(chip, "big-core", pnv->big_core, + &error_fatal); /* * The POWER8 machine use the XICS interrupt interface. * Propagate the XICS fabric to the chip and its controllers. @@ -1175,11 +1202,17 @@ static void pnv_get_pir_tir_p9(PnvChip *chip, uint32_t core_id, uint32_t thread_id, uint32_t *pir, uint32_t *tir) { - if (pir) { - if (chip->nr_threads =3D=3D 8) { - *pir =3D (chip->chip_id << 8) | ((thread_id & 1) << 2) | - (core_id << 3) | (thread_id >> 1); - } else { + if (chip->big_core) { + /* Big-core interleaves thread ID between small-cores */ + thread_id <<=3D 1; + thread_id |=3D core_id & 1; + core_id >>=3D 1; + + if (pir) { + *pir =3D (chip->chip_id << 8) | (core_id << 3) | thread_id; + } + } else { + if (pir) { *pir =3D (chip->chip_id << 8) | (core_id << 2) | thread_id; } } @@ -1203,11 +1236,17 @@ static void pnv_get_pir_tir_p10(PnvChip *chip, uint32_t core_id, uint32_t thread_id, uint32_t *pir, uint32_t *tir) { - if (pir) { - if (chip->nr_threads =3D=3D 8) { - *pir =3D (chip->chip_id << 8) | ((core_id / 4) << 4) | - ((core_id % 2) << 3) | thread_id; - } else { + if (chip->big_core) { + /* Big-core interleaves thread ID between small-cores */ + thread_id <<=3D 1; + thread_id |=3D core_id & 1; + core_id >>=3D 1; + + if (pir) { + *pir =3D (chip->chip_id << 8) | (core_id << 3) | thread_id; + } + } else { + if (pir) { *pir =3D (chip->chip_id << 8) | (core_id << 2) | thread_id; } } @@ -2180,7 +2219,8 @@ static void pnv_chip_power10_class_init(ObjectClass *= klass, void *data) &k->parent_realize); } =20 -static void pnv_chip_core_sanitize(PnvChip *chip, Error **errp) +static void pnv_chip_core_sanitize(PnvMachineState *pnv, PnvChip *chip, + Error **errp) { PnvChipClass *pcc =3D PNV_CHIP_GET_CLASS(chip); int cores_max; @@ -2201,6 +2241,17 @@ static void pnv_chip_core_sanitize(PnvChip *chip, Er= ror **errp) } chip->cores_mask &=3D pcc->cores_mask; =20 + /* Ensure small-cores a paired up in big-core mode */ + if (pnv->big_core) { + uint64_t even_cores =3D chip->cores_mask & 0x5555555555555555ULL; + uint64_t odd_cores =3D chip->cores_mask & 0xaaaaaaaaaaaaaaaaULL; + + if (even_cores ^ (odd_cores >> 1)) { + error_setg(errp, "warning: unpaired cores in big-core mode !"); + return; + } + } + /* now that we have a sane layout, let check the number of cores */ cores_max =3D ctpop64(chip->cores_mask); if (chip->nr_cores > cores_max) { @@ -2224,7 +2275,7 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) } =20 /* Cores */ - pnv_chip_core_sanitize(chip, &error); + pnv_chip_core_sanitize(pnv, chip, &error); if (error) { error_propagate(errp, error); return; @@ -2255,6 +2306,8 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) &error_fatal); object_property_set_int(OBJECT(pnv_core), "hrmor", pnv->fw_load_ad= dr, &error_fatal); + object_property_set_bool(OBJECT(pnv_core), "big-core", chip->big_c= ore, + &error_fatal); object_property_set_link(OBJECT(pnv_core), "chip", OBJECT(chip), &error_abort); qdev_realize(DEVICE(pnv_core), NULL, &error_fatal); @@ -2288,6 +2341,7 @@ static Property pnv_chip_properties[] =3D { DEFINE_PROP_UINT32("nr-cores", PnvChip, nr_cores, 1), DEFINE_PROP_UINT64("cores-mask", PnvChip, cores_mask, 0x0), DEFINE_PROP_UINT32("nr-threads", PnvChip, nr_threads, 1), + DEFINE_PROP_BOOL("big-core", PnvChip, big_core, false), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 8cfa94fbfa..6dc05534d7 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -249,7 +249,12 @@ static void pnv_core_cpu_realize(PnvCore *pc, PowerPCC= PU *cpu, Error **errp, pir_spr->default_value =3D pir; tir_spr->default_value =3D tir; =20 - env->core_index =3D core_hwid; + if (pc->big_core) { + /* 2 "small cores" get the same core index for SMT operations */ + env->core_index =3D core_hwid >> 1; + } else { + env->core_index =3D core_hwid; + } =20 /* Set time-base frequency to 512 MHz */ cpu_ppc_tb_init(env, PNV_TIMEBASE_FREQ); @@ -354,6 +359,7 @@ static void pnv_core_unrealize(DeviceState *dev) static Property pnv_core_properties[] =3D { DEFINE_PROP_UINT32("hwid", PnvCore, hwid, 0), DEFINE_PROP_UINT64("hrmor", PnvCore, hrmor, 0), + DEFINE_PROP_BOOL("big-core", PnvCore, big_core, false), DEFINE_PROP_LINK("chip", PnvCore, chip, TYPE_PNV_CHIP, PnvChip *), DEFINE_PROP_END_OF_LIST(), }; --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147387; cv=none; d=zohomail.com; s=zohoarc; b=Q01FFnMgorl19yenACeIey5D4lBvYbcQALF7WdOmygJ9sTbBg+6z2tRfIj1kc4nZTvfk/aTWvAueTMsHC3wxSKmKM1momH1rZ6xK8GQA50qjvkJJ9ujLmQ0bRV2yLwjwUhw3ST9I1VI+UG8q7LYPabiyI9gMu8c6wnf8AO4ZtY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147387; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sqArnmvQ/vJDjlGwKA+4gw/JcAXFrp1FmAC8/CBrsWI=; b=kAUjDdOqAfUVK6Y6YF6zWzcTgfgOpIiVmZ3F+j40g84VD4ODqTAX5L6utZH/F45nYykL8XlxWks+L0NjFRUXcv9g0KIoo9ZRcGhnPDVO+14Ch0tQjFb5o7xp1ZohcdVzWojfCge9Pchs0SsmAk1jLLfDrpKE72JTcQ0Kgyk8kHM= 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 1721147387376448.36454383650903; Tue, 16 Jul 2024 09:29:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2P-0002bw-KI; Tue, 16 Jul 2024 12:28:25 -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 1sTl1C-0006PN-Qb; Tue, 16 Jul 2024 12:27:13 -0400 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl1A-0006aP-CE; Tue, 16 Jul 2024 12:27:10 -0400 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-25e0c0df558so2369974fac.0; Tue, 16 Jul 2024 09:27:07 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147226; x=1721752026; darn=nongnu.org; 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=sqArnmvQ/vJDjlGwKA+4gw/JcAXFrp1FmAC8/CBrsWI=; b=aOmrYoP1pMZq7Z8YwSSLE/PZjtyeNNOe+sF4uhQSium2Sqgy4RLoMuqBd6NeC0Yl07 IUtzMh2TwV5ATBBPnKKf0OLvCg0QfqpbtRE5VwnztBS2GOcmlIv9HnmyGruTPrt2r/6/ rOojpzaPEEb5Y8U2RdCLemexEisZt3vgX47FbQDmLhKp3jZvoSFz7ss8odaLYkqCzPRY bfQqfAMcBgNq2ESjV9cDWrsbvIqf1FaZc7zoOLc9yDDjJmefNBBUAY7Pmvb8d7OV8q2X jG55Vs1hZ2EMbiaZXg7RLW1Jal6i/ooC9FckFTNlEqTUKQipLI/Xg0jVXAvo8zi1VAxN C2Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147226; x=1721752026; 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=sqArnmvQ/vJDjlGwKA+4gw/JcAXFrp1FmAC8/CBrsWI=; b=SB2S2OIPHEV/7aLqzahyUyJ4Hg0lrPilBvKx8e14yBN+rsAct3xGiTkx6Pucb51XE+ u4OnL+EU/JnTrm7GuGF1GI7dgtlPCqBrXdqJ6reaGWZ4/JTr44lLccd62/amse/hii3Q 3gHziLAnsKUd/J0Gy1pBw63NFbwhm+YOZdF40tM+0tShKViMueC0cyvkG49bjmE72G1i MjSK2dTIWy4DCzN3ectVs8ayhvmKYFUATrDXHcUZcG4t/HBM09y/UNFbblyt1uP3z1TR GbLn/lQF4OCsHIvpRi1JB4V90ncItRRRC6SKGEQifCi6lg9fuuLVf/GJg9NboPqZgkNI kZxw== X-Forwarded-Encrypted: i=1; AJvYcCWxdwhUvn9fbSjfZpd6ArWt0H6+orC9tHzZ6Oz9B4hFevQfvRic2P+NU7C+TCsWWbczW6acZn694PNTcC4g379j1RyjTkk= X-Gm-Message-State: AOJu0Yx7jaLNxYNvzVoFdgvn8EIOiNE6z0oFsq45vT/iRJ2s4u8HOMTK mE6XpchNa90r+07dQyMFj3bdMgiM9i+gkRwRJ4w7xcN4HEM5F1dRJROIAQ== X-Google-Smtp-Source: AGHT+IG9i9FrA/O+kBq2GYmeyMWeyu5koMxf3KYBVUtV1AgtQLkemKmITO++YGiSN96A4zEaystvBA== X-Received: by 2002:a05:6870:8992:b0:25e:b825:94db with SMTP id 586e51a60fabf-260bdfefa7dmr2215686fac.48.1721147226542; Tue, 16 Jul 2024 09:27:06 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH v3 11/19] ppc/pnv: Add allow for big-core differences in DT generation Date: Wed, 17 Jul 2024 02:26:07 +1000 Message-ID: <20240716162617.32161-12-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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=2001:4860:4864:20::33; envelope-from=npiggin@gmail.com; helo=mail-oa1-x33.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 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: 1721147388919116600 Content-Type: text/plain; charset="utf-8" device-tree building needs to account for big-core mode, because it is driven by qemu cores (small cores). Every second core should be skipped, and every core should describe threads for both small-cores that make up the big core. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- hw/ppc/pnv.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index d902860ecd..1d08176b75 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -141,9 +141,9 @@ static int pnv_dt_core(PnvChip *chip, PnvCore *pc, void= *fdt) CPUPPCState *env =3D &cpu->env; PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cs); PnvChipClass *pnv_cc =3D PNV_CHIP_GET_CLASS(chip); - g_autofree uint32_t *servers_prop =3D g_new(uint32_t, smt_threads); + uint32_t *servers_prop; int i; - uint32_t pir; + uint32_t pir, tir; uint32_t segs[] =3D {cpu_to_be32(28), cpu_to_be32(40), 0xffffffff, 0xffffffff}; uint32_t tbfreq =3D PNV_TIMEBASE_FREQ; @@ -154,7 +154,10 @@ static int pnv_dt_core(PnvChip *chip, PnvCore *pc, voi= d *fdt) char *nodename; int cpus_offset =3D get_cpus_node(fdt); =20 - pnv_cc->get_pir_tir(chip, pc->hwid, 0, &pir, NULL); + pnv_cc->get_pir_tir(chip, pc->hwid, 0, &pir, &tir); + + /* Only one DT node per (big) core */ + g_assert(tir =3D=3D 0); =20 nodename =3D g_strdup_printf("%s@%x", dc->fw_name, pir); offset =3D fdt_add_subnode(fdt, cpus_offset, nodename); @@ -235,12 +238,28 @@ static int pnv_dt_core(PnvChip *chip, PnvCore *pc, vo= id *fdt) } =20 /* Build interrupt servers properties */ - for (i =3D 0; i < smt_threads; i++) { - pnv_cc->get_pir_tir(chip, pc->hwid, i, &pir, NULL); - servers_prop[i] =3D cpu_to_be32(pir); + if (pc->big_core) { + servers_prop =3D g_new(uint32_t, smt_threads * 2); + for (i =3D 0; i < smt_threads; i++) { + pnv_cc->get_pir_tir(chip, pc->hwid, i, &pir, NULL); + servers_prop[i * 2] =3D cpu_to_be32(pir); + + pnv_cc->get_pir_tir(chip, pc->hwid + 1, i, &pir, NULL); + servers_prop[i * 2 + 1] =3D cpu_to_be32(pir); + } + _FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", + servers_prop, sizeof(*servers_prop) * smt_threads + * 2))); + } else { + servers_prop =3D g_new(uint32_t, smt_threads); + for (i =3D 0; i < smt_threads; i++) { + pnv_cc->get_pir_tir(chip, pc->hwid, i, &pir, NULL); + servers_prop[i] =3D cpu_to_be32(pir); + } + _FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", + servers_prop, sizeof(*servers_prop) * smt_thread= s))); } - _FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", - servers_prop, sizeof(*servers_prop) * smt_threads))= ); + g_free(servers_prop); =20 return offset; } @@ -389,6 +408,10 @@ static void pnv_chip_power9_dt_populate(PnvChip *chip,= void *fdt) =20 _FDT((fdt_setprop(fdt, offset, "ibm,pa-features", pa_features_300, sizeof(pa_features_300)))); + + if (pnv_core->big_core) { + i++; /* Big-core groups two QEMU cores */ + } } =20 if (chip->ram_size) { @@ -450,6 +473,10 @@ static void pnv_chip_power10_dt_populate(PnvChip *chip= , void *fdt) =20 _FDT((fdt_setprop(fdt, offset, "ibm,pa-features", pa_features_31, sizeof(pa_features_31)))); + + if (pnv_core->big_core) { + i++; /* Big-core groups two QEMU cores */ + } } =20 if (chip->ram_size) { --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147360; cv=none; d=zohomail.com; s=zohoarc; b=gDvVxy8VviyRzkZCzQiRyCDku/j5738bgwP/9LQvPQ2lqD3fCzA7kVRLuO5LufYR62/SQYjz9AeWmuq9Wy+tU5rond75H9Q0A9KQs3OwrpmUmr6UKGj+wmM1jfQ+/1eocRmIgmCm3enmBRRcpPyuj0mS6+JhUmgTs/ZDNkjbW6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147360; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RNZWaeAaQd+FgPrD7L1WMdXukzJbPCdt43L1w3ipbZg=; b=eEnJ3X+eIj4OOXCpan6wO7z37goVG8nE+QMM1W/ugtuj9w1e/aOlTD3FBBsQ009zfCVyHDwooQ7IXBLSqndE3zKjg5Wc9rtn5AcCOFltIKqjhXXc8LWTUEhEWXgXP9sh11piO/vbzZ+/9JhjVkb9+32vtDVJomPxXMjRqP5GCYU= 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 1721147360804644.7800978698534; Tue, 16 Jul 2024 09:29:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2M-00021D-6B; Tue, 16 Jul 2024 12:28:22 -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 1sTl1J-0006VV-K0; Tue, 16 Jul 2024 12:27:19 -0400 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl1F-0006bt-RL; Tue, 16 Jul 2024 12:27:16 -0400 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-25e134abf00so2810986fac.1; Tue, 16 Jul 2024 09:27:12 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147230; x=1721752030; darn=nongnu.org; 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=RNZWaeAaQd+FgPrD7L1WMdXukzJbPCdt43L1w3ipbZg=; b=mE71lWa1v1qDE/6ErfLgBoIRWJs9b8rb2OMtKuUiO0Xx3TegYRuy6zUPDSoL+zVgL3 tkL4ROMzKlGPN9Ga+NfLbnP2AyTHAxtkQ+egjBuF7AIFqsZSdwUgISihnpA0sR9JvRbI 1yn6MAPG1ichwo0WK1P6/qg0GuVY2MZfI5xwETqycvC65gBSJNHdpZvvJcuE6464g/hE +hnJlv0QY6tGDt7C1PxuG6aAkD8Y0ARa/gPC9KJt/sD8nsy95G4uTocp0lKgZoFERLoQ Nylv430tdWhJP5b18FpxYvcbmhAWiJuEe+Y6AfUKdBYLTQ/qonMc7ysPU0qEU2k3FIbj znAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147230; x=1721752030; 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=RNZWaeAaQd+FgPrD7L1WMdXukzJbPCdt43L1w3ipbZg=; b=wXM0yXuD3V/VJtzZmXEy8qq4F/p0rf76oazzPsBpCzZnw9iQwm5K9/XZTDrHioTDeq /pAoxaKlt2o2rp4EDzuj6tfN5orp+ccw7OuuQiQPVVZNRYOJn77v/u8m8gXF7CoM9TIA ukv02RheXyM3GSQgbUpVJNjM2awo9Kc0KJolzWAgLbE6B36OzaLAe2pt4CYqIcKPJp4V 388sS5L+nMIU4OYb+2H9YXRkhRXKmC2P4JDb91bCf2Dcbdp5nbAnIEHjLTAC0OsryMGz lOVZjE8XdEt92Ar09/idDbNnK7UWwe4nKhs9ico0TLUYMUHbHh/DRaKROznda5ISQL+M 1EHw== X-Forwarded-Encrypted: i=1; AJvYcCUVBCzZ2zSFjmN9piSosrsSZGwj7DOVt2ZcjRDcMP3z9uJTls1ikW0FImLUht7KbXqu9jkbqhvQlsSr3vEuJUnps06P35E= X-Gm-Message-State: AOJu0Yzu1ef3tH3+iCtVW9atZYMcnYFiuf5smVCvxT+M91clWmR8FolA mGboFvNj3CgNAXgf5L0kAH16J0OSIRV8bP4jWa7b39VGjvIdJD7j6KBOZA== X-Google-Smtp-Source: AGHT+IEyiUUhnKUIXWWM3ddqsHvRndyuL9HtRyw0F+VlNDRYkFMvZgafga3Tg50dngvSzIuvG/1Pwg== X-Received: by 2002:a05:6870:6489:b0:23d:a1d0:7334 with SMTP id 586e51a60fabf-260bd5bdb07mr2051825fac.17.1721147230428; Tue, 16 Jul 2024 09:27:10 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v3 12/19] ppc/pnv: Implement big-core PVR for Power9/10 Date: Wed, 17 Jul 2024 02:26:08 +1000 Message-ID: <20240716162617.32161-13-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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=2001:4860:4864:20::32; envelope-from=npiggin@gmail.com; helo=mail-oa1-x32.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 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: 1721147362785116600 Power9/10 CPUs have PVR[51] set in small-core mode and clear in big-core mode. This is used by skiboot firmware. PVR is not hypervisor-privileged but it is not so important that spapr to implement this because it's generally masked out of PVR matching code in kernels, and only used by firmware. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- hw/ppc/pnv_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 6dc05534d7..43cfeaa2d4 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -58,6 +58,10 @@ static void pnv_core_cpu_reset(PnvCore *pc, PowerPCCPU *= cpu) env->nip =3D 0x10; env->msr |=3D MSR_HVB; /* Hypervisor mode */ env->spr[SPR_HRMOR] =3D pc->hrmor; + if (pc->big_core) { + /* Clear "small core" bit on Power9/10 (this is set in default PVR= ) */ + env->spr[SPR_PVR] &=3D ~PPC_BIT(51); + } hreg_compute_hflags(env); ppc_maybe_interrupt(env); =20 --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147393; cv=none; d=zohomail.com; s=zohoarc; b=QQtCyaghPIREoL6U7l0e7F+Iu6Lm4Hx8JNO7SDrqbdJv+EIv/r16eQZrTbb2YNbbjvirvg/hQGyZgv7O4fr8SnQNP9EOfIuR3Fra6DR48F+TWE6LKdv0TUAAZbiP41ox8xajhmJWEYnPhL7szC4KJmb+IcbeCeoi9Id8lz7eKQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147393; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tyPOIb2VK3dD8F4THz9rJokTRHuUTmaR6trLMdHrvl0=; b=IiPOt/p087SBbia0DMMh/tdIDpaIqP+6IqKUdh1BMAfjcllghb/GhpcdyQav4wIUPMnLf+IvEwCEF4tZVFGDqu1q8muzEDpzhPCES7XEs5SByDuzh+cqSGS9biQWRTIcSjEdQkOHloOZlkpkg9O6TQEdxWt8iDs1EouiO19l70Q= 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 17211473930221004.5880383295338; Tue, 16 Jul 2024 09:29:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2S-000303-SV; Tue, 16 Jul 2024 12:28:28 -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 1sTl1K-0006XA-1z; Tue, 16 Jul 2024 12:27:19 -0400 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl1I-0006cN-7E; Tue, 16 Jul 2024 12:27:17 -0400 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-25e00f348e6so3141107fac.1; Tue, 16 Jul 2024 09:27:15 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147234; x=1721752034; darn=nongnu.org; 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=tyPOIb2VK3dD8F4THz9rJokTRHuUTmaR6trLMdHrvl0=; b=iUlodgZ488qDY1iBEs5cF2EZeeopKbXggh7GaEPzM6OITVfrF0tOAmnBZPWPyF+ciK eZG94lHILxALY3MXAUy56erTK8m6kxbfQZetagvu2djWgw6v2HlE+5Bat7g+iPyna0+v uPlCe9YZePx+VDl0GPez2Y1DKQzSnZbIsd5WxkVqxR2dTVvV+KS/lv/IxsFrcKiFQFe7 NuWlSEW8LU4Rd0EPgGZBmmyq382HKicrhbPZ3mZB21AKmpjbfEHiJWCuwIWAhXJXJ9LP cGQVZ/R1le1u904IB6TnfLXk58lve0jkSqlM2vBlwy2QUvBaDYsobQ/MPFcyXelqfTyc CRnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147234; x=1721752034; 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=tyPOIb2VK3dD8F4THz9rJokTRHuUTmaR6trLMdHrvl0=; b=VaBQRX6I6lxLZTeFB5xWnjaioGn4Rne78EpCHdp/UKbHAtoWvUlor86wXpJXafzIiY hb8baPnRA6uPOe8Zxf9UdZWZ5fXVnzOS1j06Y4jyzUhU8urMm9kU0+b2k/f2wjK2ea4u FCoqhkHrG0GJar2R/1YaBjNpRfN5PIOEff45toyXHBzFM7sxlcovY1G0Z99bavBf0LUN o+Y4YAcwelYXVTxWMviJIKbtpzKKRqVRUDzHyn9KEW+pK+65ea0aaEmxPudvRSU+632p lTqOgPA0hknIbN/xCKtlyy1zW9aOiPCIh4onmOkH/p/BgJTgiceCefAGzLcUi4IY56Bs 7Ktg== X-Forwarded-Encrypted: i=1; AJvYcCXrfpuw/CMQ87jLR/b79/8os+Njgk2PatoM5jSO5nAphwQwVK4fKgkVBfcryyvsWwfCliL0HKpZsNPR/Lz8CZjNNI3REoM= X-Gm-Message-State: AOJu0YxA1lU0lvZInPv5x0JH5CBvEPG7FspL/e/hqH9Hvah2hyIkc7lQ ZfUBi0W+fATNk1AITWgk/lJo0VHJNgXf9Kx1kjltEuZL3AWysrAnk7ngeQ== X-Google-Smtp-Source: AGHT+IH1G7haDJ80o4RXttZ9v+RvaZNkthlUOhSX+Njl8qCD5Ag07eiR83L7fH89xKeCjBAX1Tw6Fw== X-Received: by 2002:a05:6870:d189:b0:25e:b999:d24 with SMTP id 586e51a60fabf-260bd9cfee0mr1972510fac.0.1721147234009; Tue, 16 Jul 2024 09:27:14 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH v3 13/19] ppc/pnv: Implement Power9 CPU core thread state indirect register Date: Wed, 17 Jul 2024 02:26:09 +1000 Message-ID: <20240716162617.32161-14-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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=2001:4860:4864:20::2a; envelope-from=npiggin@gmail.com; helo=mail-oa1-x2a.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 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: 1721147394956116600 Content-Type: text/plain; charset="utf-8" Power9 CPUs have a core thread state register accessible via SPRC/SPRD indirect registers. This register includes a bit for big-core mode, which skiboot requires. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- target/ppc/misc_helper.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index 692e48e6bc..e69236d2de 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -319,6 +319,23 @@ target_ulong helper_load_sprd(CPUPPCState *env) case 0: /* SCRATCH0-3 */ case 1: /* SCRATCH4-7 */ return pc->scratch[(sprc >> 3) & 0x7]; + + case 0x1e0: /* core thread state */ + if (env->excp_model =3D=3D POWERPC_EXCP_POWER9) { + /* + * Only implement for POWER9 because skiboot uses it to check + * big-core mode. Other bits are unimplemented so we would + * prefer to get unimplemented message on POWER10 if it were + * used anywhere. + */ + if (pc->big_core) { + return PPC_BIT(63); + } else { + return 0; + } + } + /* fallthru */ + default: qemu_log_mask(LOG_UNIMP, "mfSPRD: Unimplemented SPRC:0x" TARGET_FMT_lx"\n", sprc); --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147491; cv=none; d=zohomail.com; s=zohoarc; b=S99AAP+d6y+HN+JIucw8Vi7Tfzz1q9e2Qwfiij+TgPX7uZYD/doLRSPGpjg29hdKJOCP9GtL9Llrn2IwWhStS4JkEgBFaou2m2tjp56Y8TyJs8n4X+S9I/n46EhmumYHwU1/W2aHBNULBLIb/OUfMwmskkGgukK042uHpKjOSN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147491; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3Njtj68/O8+IW2jvRZMh3SlkL4jNiwEp56S0K4b4BOQ=; b=M4kPH57VozFk7cTO0YUmf27vzI8B021k+le9L4HcV9nmsP6vFUI9uIvGtl+oHx9hAMJjUgw/ipni/FjZQTT6jb+yYdrKgvrkYKhGuusGFohgFbOxw+A+rRc+E2QHcBXLm4mWCDgJNknd+zle+hJ25+ymT+vKTQwN6NvyalpikqY= 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 172114749132313.195684616511244; Tue, 16 Jul 2024 09:31:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2T-0003E2-A3; Tue, 16 Jul 2024 12:28:29 -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 1sTl1b-0007B0-65; Tue, 16 Jul 2024 12:27:36 -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 1sTl1M-0006cu-8N; Tue, 16 Jul 2024 12:27:22 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-70b0e7f6f8bso4983722b3a.3; Tue, 16 Jul 2024 09:27:19 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147237; x=1721752037; darn=nongnu.org; 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=3Njtj68/O8+IW2jvRZMh3SlkL4jNiwEp56S0K4b4BOQ=; b=m+mCQsNAhSDlb0fGWBvqjixmjvTKb96mpzye10uhPMA4fllCipFjH85f+sOVVneORJ ZKP0rxae+JPYrmrV1RQRSGwFDYhMrpfPewCFT7OECvBR2bvHo9XVwfck7ylgrtaT1zse 4+6c8dlECLGVcf8ZhriWeGhRdy1x7IDZcDQaQ4dIZdRoUdD9bBa3uCjox6X6hhso361v ZyN5YxEbMGSlcn856UNxsm56B0Zf3CF+NFt0oT8QMFrW+FTjqlfdommL9sBPoJTOxoLu oOO21GGZ3BCN/8lrHlpJOvN1LobzQae9pyUECHddPLDilNhSxO7cO5vdGmOx27EzFQNA 9jew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147237; x=1721752037; 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=3Njtj68/O8+IW2jvRZMh3SlkL4jNiwEp56S0K4b4BOQ=; b=BuUapqnUzpKr3TNpDmKAICpQDTu2mXg1jMk4YfJu8UHe3j5XdhHecR3baiW9JedIxR kYZ91hraJt25cxI3NgPhLSM3s+hFLA6VTXBoW8MjsP8eHsgbH+EmGTr+2FeOdCUBj6fn dJKCCEEv+YkSK8RWbE/vnIuGfbHsRN25VzALNKDNFNPfrQWnsxEBmFmcgb08/N51FqQ4 qH7EAe8H1EYkTHM9rYtFz9aPuYPPkji/nZfyGo6SndoAIaSQ4f83O7czLsgfYDF9Ndvl dDe7ZN4pBxbiMoJPVciyAmwDhcXyC1x6EgjcRbX0OMwYxgAVqFnfMZ0VJiVQeMtGVYoC 3Mew== X-Forwarded-Encrypted: i=1; AJvYcCUDTFJc2oBn1YuI9FWEb18oJERxIvEPOCzmRoXolT3P2T4ydS+ZuPHg4fC54pdCYN+c7GyqE22U2eeccoLnLcpP9EiHSIc= X-Gm-Message-State: AOJu0YwFH4o13dnod/SsIm6PNHe19HPUcXkxbIUiW56oVK4QILgh46XN OAjJRIJrneKTdrzqp5Hy1XMfeZ4U5i4OUHu6PN8JFzM8eqP5VTw8xTteQw== X-Google-Smtp-Source: AGHT+IGUcLO+DOsEDizjEL8gRWiv+J6cmM9jlYyhz5lEjJ+96WneJ+jmT3tS05vZRFWJ3a68TsZZmg== X-Received: by 2002:aa7:8891:0:b0:707:ffa4:de3f with SMTP id d2e1a72fcca58-70c1fbe3451mr3442654b3a.17.1721147237466; Tue, 16 Jul 2024 09:27:17 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH v3 14/19] ppc/pnv: Add POWER10 ChipTOD quirk for big-core Date: Wed, 17 Jul 2024 02:26:10 +1000 Message-ID: <20240716162617.32161-15-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::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 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: 1721147493400116600 Content-Type: text/plain; charset="utf-8" POWER10 has a quirk in its ChipTOD addressing that requires the even small-core to be selected even when programming the odd small-core. This allows skiboot chiptod init to run in big-core mode. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv.h | 1 + include/hw/ppc/pnv_core.h | 7 +++++++ hw/ppc/pnv.c | 7 ++++++- hw/ppc/pnv_core.c | 2 ++ target/ppc/timebase_helper.c | 9 +++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 283ddd50e7..c56d152889 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -77,6 +77,7 @@ struct PnvMachineClass { const char *compat; int compat_size; int max_smt_threads; + bool quirk_tb_big_core; =20 void (*dt_power_mgt)(PnvMachineState *pnv, void *fdt); void (*i2c_init)(PnvMachineState *pnv); diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h index 50164e9e1f..c8784777a4 100644 --- a/include/hw/ppc/pnv_core.h +++ b/include/hw/ppc/pnv_core.h @@ -27,6 +27,13 @@ =20 /* Per-core ChipTOD / TimeBase state */ typedef struct PnvCoreTODState { + /* + * POWER10 DD2.0 - big core TFMR drives the state machine on the even + * small core. Skiboot has a workaround that targets the even small co= re + * for CHIPTOD_TO_TB ops. + */ + bool big_core_quirk; + int tb_ready_for_tod; /* core TB ready to receive TOD from chiptod */ int tod_sent_to_tb; /* chiptod sent TOD to the core TB */ =20 diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 1d08176b75..322ab9073b 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2290,11 +2290,12 @@ static void pnv_chip_core_sanitize(PnvMachineState = *pnv, PnvChip *chip, =20 static void pnv_chip_core_realize(PnvChip *chip, Error **errp) { + PnvMachineState *pnv =3D PNV_MACHINE(qdev_get_machine()); + PnvMachineClass *pmc =3D PNV_MACHINE_GET_CLASS(pnv); Error *error =3D NULL; PnvChipClass *pcc =3D PNV_CHIP_GET_CLASS(chip); const char *typename =3D pnv_chip_core_typename(chip); int i, core_hwid; - PnvMachineState *pnv =3D PNV_MACHINE(qdev_get_machine()); =20 if (!object_class_by_name(typename)) { error_setg(errp, "Unable to find PowerNV CPU Core '%s'", typename); @@ -2335,8 +2336,11 @@ static void pnv_chip_core_realize(PnvChip *chip, Err= or **errp) &error_fatal); object_property_set_bool(OBJECT(pnv_core), "big-core", chip->big_c= ore, &error_fatal); + object_property_set_bool(OBJECT(pnv_core), "quirk-tb-big-core", + pmc->quirk_tb_big_core, &error_fatal); object_property_set_link(OBJECT(pnv_core), "chip", OBJECT(chip), &error_abort); + qdev_realize(DEVICE(pnv_core), NULL, &error_fatal); =20 /* Each core has an XSCOM MMIO region */ @@ -2650,6 +2654,7 @@ static void pnv_machine_p10_common_class_init(ObjectC= lass *oc, void *data) pmc->compat =3D compat; pmc->compat_size =3D sizeof(compat); pmc->max_smt_threads =3D 4; + pmc->quirk_tb_big_core =3D true; pmc->dt_power_mgt =3D pnv_dt_power_mgt; =20 xfc->match_nvt =3D pnv10_xive_match_nvt; diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 43cfeaa2d4..1783795b23 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -364,6 +364,8 @@ static Property pnv_core_properties[] =3D { DEFINE_PROP_UINT32("hwid", PnvCore, hwid, 0), DEFINE_PROP_UINT64("hrmor", PnvCore, hrmor, 0), DEFINE_PROP_BOOL("big-core", PnvCore, big_core, false), + DEFINE_PROP_BOOL("quirk-tb-big-core", PnvCore, tod_state.big_core_quir= k, + false), DEFINE_PROP_LINK("chip", PnvCore, chip, TYPE_PNV_CHIP, PnvChip *), DEFINE_PROP_END_OF_LIST(), }; diff --git a/target/ppc/timebase_helper.c b/target/ppc/timebase_helper.c index 44cacf065e..019b8ee41f 100644 --- a/target/ppc/timebase_helper.c +++ b/target/ppc/timebase_helper.c @@ -20,6 +20,7 @@ #include "cpu.h" #include "hw/ppc/ppc.h" #include "hw/ppc/pnv_core.h" +#include "hw/ppc/pnv_chip.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" #include "qemu/log.h" @@ -297,6 +298,14 @@ static PnvCoreTODState *cpu_get_tbst(PowerPCCPU *cpu) { PnvCore *pc =3D pnv_cpu_state(cpu)->pnv_core; =20 + if (pc->big_core && pc->tod_state.big_core_quirk) { + /* Must operate on the even small core */ + int core_id =3D CPU_CORE(pc)->core_id; + if (core_id & 1) { + pc =3D pc->chip->cores[core_id & ~1]; + } + } + return &pc->tod_state; } =20 --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147329; cv=none; d=zohomail.com; s=zohoarc; b=h3aVQV1HHaOn15LW10q5Ni+8NYKeZQDvpePFl4zvNKvbBulM+rcQfLwpBxZs4S6tnxYIZwJgRZEOpHZZH+/fRDIk9Bnoak01dLfgIQ+YSqOluLXpAaVOI1o0/xle5n3ciwHu0Yz3IWwzVW92scnYhUAx7SIEV8zbpbBm4o9kjho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147329; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CFw001e7GD8WEMem20VntnHs8lxAIjbQ2/80VeZWCz4=; b=Bu0jUL3RP5INtqVDphUGUK7g9JSilDSQZKHTxMKh2gMmJNlKyH8MdHfUE4a3nvpzMZNURnZRIxSN4gBOUlinL22G9h00VKl1kGOMa0MsWreq+fkS7n9CA6BDPf7dnY5ZY9Io1VjWoCaBs3jKrETvi3hLHG6a3q0Et7bZU6U8L5I= 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 1721147329597433.1403195536918; Tue, 16 Jul 2024 09:28:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2S-000389-HP; Tue, 16 Jul 2024 12:28:28 -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 1sTl1f-0007RV-Mi; Tue, 16 Jul 2024 12:27:40 -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 1sTl1b-0006dX-Bs; Tue, 16 Jul 2024 12:27:39 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-70cdc91b227so449691b3a.2; Tue, 16 Jul 2024 09:27:22 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147241; x=1721752041; darn=nongnu.org; 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=CFw001e7GD8WEMem20VntnHs8lxAIjbQ2/80VeZWCz4=; b=XV9Qs9ZO0Q/3TLIqOwU01tSWA25uWYR+LRXMy/gQQAUUesgI0XB73TaDMITS4pbgw8 AP/9yjAQgKvCPzsH1SD2e3frCyAtMpRlA+gu9I6eNof7NstTTWIog09q5zlAmHl8A8C+ /+nbgAVfLHC/cies8NjHLiwf6Eu8xh2q99wWCobnhZYSe80JyvZkZkJ8OZ890peElNcn pA3uYq5SNF/a0IJ31Vb5ud19ScpXJmqjNMBuLWVURBs+F3reNYe54SeX4EopiLfPZe9C CVkocLE6zEAbF9b/v5HFmxjJZclPimFOr5sMUWfjepeSy6OdyVUhnj66n1bPr0HWY5qv 4QYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147241; x=1721752041; 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=CFw001e7GD8WEMem20VntnHs8lxAIjbQ2/80VeZWCz4=; b=V4CriB0G/toYN4q5KUsywCvgwRrKiSzURoyZwYWH9uWjaNvN9ahGUxhQezHnR//pJL eR8Ubc9XyqUdjQUQzX9L/BNRTKup758od1xau+ZKzu2I6auQZk0cxezGrekaT0wcvYml BD+CioFzJYsGi4P+E6QvmbWUDyJ0WpOtSX2jHLx68+VrAzpg1QOyXRWy6etQSH+Yx4lw z5nKp3Visf4qEGGnIC3WUG9g9rMasJzgMDscKeIrGSTM1/s9IIUyu0EMzLDhWcsvLW+3 Zs+Fh+G6gXau2tV7VjxGpr/0LNlza8EzPsFPq4fc7eZz9QOu3Uo+c2I+CU+l0BGjJal4 zJNg== X-Forwarded-Encrypted: i=1; AJvYcCUOl/wFP+eHj2GobBi7pfIZUHTEO49GylcJQ52T9ZANkRdInNQwtZUyG/tFaS77b0BD2uVzkdY4fGs5Sy0P5VIjB62MjWE= X-Gm-Message-State: AOJu0Yx3/lJpwkrrhc4IVdZfhSL7/8mgLBU3/fW/EhzlWQBk/hs3lZA6 qvu4/nOu9nq5HGrIWEmkGgagarSrHQtbRM08qbPlhG8Y+bdR35USYkkUjw== X-Google-Smtp-Source: AGHT+IHJ8Lgkvexh+kbDIxR+lTp85v4LVe9wJZMycbu3OE/wnfLFbFqjH+GdRrkBHFOFirJ3MvBJYw== X-Received: by 2002:a05:6a00:10c5:b0:706:4889:960d with SMTP id d2e1a72fcca58-70c1fbdef6cmr4240437b3a.16.1721147240939; Tue, 16 Jul 2024 09:27:20 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH v3 15/19] ppc/pnv: Add big-core machine property Date: Wed, 17 Jul 2024 02:26:11 +1000 Message-ID: <20240716162617.32161-16-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::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 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: 1721147330607116600 Content-Type: text/plain; charset="utf-8" Big-core implementation is complete, so expose it as a machine property that may be set with big-core=3Don option on powernv9 and powernv10 machines. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- hw/ppc/pnv.c | 61 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 322ab9073b..08aaac359b 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2581,6 +2581,34 @@ static int pnv10_xive_match_nvt(XiveFabric *xfb, uin= t8_t format, return total_count; } =20 +static bool pnv_machine_get_big_core(Object *obj, Error **errp) +{ + PnvMachineState *pnv =3D PNV_MACHINE(obj); + return pnv->big_core; +} + +static void pnv_machine_set_big_core(Object *obj, bool value, Error **errp) +{ + PnvMachineState *pnv =3D PNV_MACHINE(obj); + pnv->big_core =3D value; +} + +static bool pnv_machine_get_hb(Object *obj, Error **errp) +{ + PnvMachineState *pnv =3D PNV_MACHINE(obj); + + return !!pnv->fw_load_addr; +} + +static void pnv_machine_set_hb(Object *obj, bool value, Error **errp) +{ + PnvMachineState *pnv =3D PNV_MACHINE(obj); + + if (value) { + pnv->fw_load_addr =3D 0x8000000; + } +} + static void pnv_machine_power8_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -2632,6 +2660,12 @@ static void pnv_machine_power9_class_init(ObjectClas= s *oc, void *data) pmc->dt_power_mgt =3D pnv_dt_power_mgt; =20 machine_class_allow_dynamic_sysbus_dev(mc, TYPE_PNV_PHB); + + object_class_property_add_bool(oc, "big-core", + pnv_machine_get_big_core, + pnv_machine_set_big_core); + object_class_property_set_description(oc, "big-core", + "Use big-core (aka fused-core) mode"); } =20 static void pnv_machine_p10_common_class_init(ObjectClass *oc, void *data) @@ -2668,6 +2702,17 @@ static void pnv_machine_power10_class_init(ObjectCla= ss *oc, void *data) =20 pnv_machine_p10_common_class_init(oc, data); mc->desc =3D "IBM PowerNV (Non-Virtualized) POWER10"; + + /* + * This is the parent of POWER10 Rainier class, so properies go here + * rather than common init (which would add them to both parent and + * child which is invalid). + */ + object_class_property_add_bool(oc, "big-core", + pnv_machine_get_big_core, + pnv_machine_set_big_core); + object_class_property_set_description(oc, "big-core", + "Use big-core (aka fused-core) mode"); } =20 static void pnv_machine_p10_rainier_class_init(ObjectClass *oc, void *data) @@ -2680,22 +2725,6 @@ static void pnv_machine_p10_rainier_class_init(Objec= tClass *oc, void *data) pmc->i2c_init =3D pnv_rainier_i2c_init; } =20 -static bool pnv_machine_get_hb(Object *obj, Error **errp) -{ - PnvMachineState *pnv =3D PNV_MACHINE(obj); - - return !!pnv->fw_load_addr; -} - -static void pnv_machine_set_hb(Object *obj, bool value, Error **errp) -{ - PnvMachineState *pnv =3D PNV_MACHINE(obj); - - if (value) { - pnv->fw_load_addr =3D 0x8000000; - } -} - static void pnv_cpu_do_nmi_on_cpu(CPUState *cs, run_on_cpu_data arg) { CPUPPCState *env =3D cpu_env(cs); --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147374; cv=none; d=zohomail.com; s=zohoarc; b=mHNsCGSc3N/nqLk1Q5iYNI4ZXbRjEfBI4H1kTMmboGo1073NzubRTPyPp7JhWZw/xVELHsGNTAQNudngyQBQKZuiME0Bu6KXNC+M3kyufNQNzPQpBJIHTIgOzTcgV3L58m2g9C+RbFMW1qHdfDvDMUQhTsaoXRGgPGVied5eYNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147374; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jbl1GeXwoz46Altpg40xcQTbbbBXwRHlgtS1l83HdP8=; b=RDuGC7chiPsJDMmIMnKutLeZTh4EaD5gZDT35/7PJnBjM7ZuKOEhrHgPUSFQ4J1Nn8iqRGcHzJU6sFB/ggejdQSWO0T+JncLxemJm+W58TqJEOK/XoK+A9rtkLO76CNp3fP0FnHhDgTTaYOVEeBP5xifE4v5qD2gjcLde2FbLxQ= 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 1721147374820640.0395771632933; Tue, 16 Jul 2024 09:29:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2Y-0004MC-Hg; Tue, 16 Jul 2024 12:28:34 -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 1sTl1f-0007RU-Ml; Tue, 16 Jul 2024 12:27:40 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl1b-0006dq-Cz; Tue, 16 Jul 2024 12:27:39 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-70af8128081so3885564b3a.1; Tue, 16 Jul 2024 09:27:26 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147245; x=1721752045; darn=nongnu.org; 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=jbl1GeXwoz46Altpg40xcQTbbbBXwRHlgtS1l83HdP8=; b=QXZwGBtaT+45R4VKUAZ0xVb+skyDG+1Y8xuoGxS4MtuQDNeiQONvNl6gFhKYmohJ+9 uJFDpAKLt1Cc/sAy7wLHmzRTFMX7yXZH6/WstcALUmxpbcIbq0+MrdVsgHegt/mZIx/r Dyu9sJNOA1Bep7FC+QM7bTonKtyDqAIrw3serSD+X/ym+EE1nOUj1Vic5A1Bb20nVwXP KxEk8dCBqCTSrIqDwH0A/K/8Re0zFKE4RA5/f50T4bd9hUU/8V+KhBJQ7zs+J31QoWZa XGCd++n0Au024uR97KZzfEoQBWRZB5qI1fUCEkrJ/5FjholgE2aggWRHzMs9N0c6WkBp BysQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147245; x=1721752045; 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=jbl1GeXwoz46Altpg40xcQTbbbBXwRHlgtS1l83HdP8=; b=tvIwMR2+eL77VvhwFtXuqUOwo6CGzu41cd3J14CfGSQ2OR1ummoRu+jKrHTGwx+e0E wpCXPOL7bVrTaJmfMVFHPmSRs1Nv+a9mXuGUB1sHvgKodAZSJYNmeweDfbyawmageb1f +3Sg4vzGvDbSHzx+i0XF7W/7KPtk3emdAR2hjnwpFlFYbZj5VMvS8PaAyoQSz+f7a1a/ jJdD6oTW8h+AxaO7BIbSA4ws8n/grWXY4xtK0it/az3PlkTwOcEHKDuNsjI52v8taVl0 A3R6biUjjYUoADhFfjSECVzuWsGZsyCTj5Rib3O4QQRT+Cx8s9EQWEWinem2UtiSD4hM +QlA== X-Forwarded-Encrypted: i=1; AJvYcCXsFkxyqBbEQ3jqldymsoexXm1cw3z/v0liMJ2EKpkF4ric7TskuPhAvDmCGFPvVELCxttiR7ydutpm3wTYgvbSo9jf2+8= X-Gm-Message-State: AOJu0YwNkZPE4WVqpVoBeJy6wtjOh8nJU9411O3KSA7I17rXlYJLFUG4 bNSl3GWiQ3stphXofpzB1sFx3W2+U17bTp9mcRVSFEhpr5zYHaEbQMMilA== X-Google-Smtp-Source: AGHT+IER5tSaxQNurxyWXwAWjSOCzVkPwWUzt6g/jxQBh+Ck87c7L3XoiXqzOCadJSPWSmaUa6DPJA== X-Received: by 2002:a05:6a00:3916:b0:706:6af8:e088 with SMTP id d2e1a72fcca58-70c1fb4a270mr3396133b3a.3.1721147245053; Tue, 16 Jul 2024 09:27:25 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH v3 16/19] system/cpus: Add cpu_pause() function Date: Wed, 17 Jul 2024 02:26:12 +1000 Message-ID: <20240716162617.32161-17-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::42d; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42d.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 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: 1721147376864116600 This factors the CPU pause function from pause_all_vcpus() into a new cpu_pause() function, similarly to cpu_resume(). cpu_resume() is moved to keep it next to cpu_pause(). Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Xu Signed-off-by: Nicholas Piggin --- include/hw/core/cpu.h | 8 ++++++++ system/cpus.c | 30 +++++++++++++++++------------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index a2c8536943..e6acfcb59a 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -984,6 +984,14 @@ void cpu_reset_interrupt(CPUState *cpu, int mask); */ void cpu_exit(CPUState *cpu); =20 +/** + * cpu_pause: + * @cpu: The CPU to pause. + * + * Pauses CPU, i.e. puts CPU into stopped state. + */ +void cpu_pause(CPUState *cpu); + /** * cpu_resume: * @cpu: The CPU to resume. diff --git a/system/cpus.c b/system/cpus.c index d3640c9503..5e3a988a0a 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -568,6 +568,22 @@ void cpu_thread_signal_destroyed(CPUState *cpu) qemu_cond_signal(&qemu_cpu_cond); } =20 +void cpu_pause(CPUState *cpu) +{ + if (qemu_cpu_is_self(cpu)) { + qemu_cpu_stop(cpu, true); + } else { + cpu->stop =3D true; + qemu_cpu_kick(cpu); + } +} + +void cpu_resume(CPUState *cpu) +{ + cpu->stop =3D false; + cpu->stopped =3D false; + qemu_cpu_kick(cpu); +} =20 static bool all_vcpus_paused(void) { @@ -588,12 +604,7 @@ void pause_all_vcpus(void) =20 qemu_clock_enable(QEMU_CLOCK_VIRTUAL, false); CPU_FOREACH(cpu) { - if (qemu_cpu_is_self(cpu)) { - qemu_cpu_stop(cpu, true); - } else { - cpu->stop =3D true; - qemu_cpu_kick(cpu); - } + cpu_pause(cpu); } =20 /* We need to drop the replay_lock so any vCPU threads woken up @@ -613,13 +624,6 @@ void pause_all_vcpus(void) bql_lock(); } =20 -void cpu_resume(CPUState *cpu) -{ - cpu->stop =3D false; - cpu->stopped =3D false; - qemu_cpu_kick(cpu); -} - void resume_all_vcpus(void) { CPUState *cpu; --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147417; cv=none; d=zohomail.com; s=zohoarc; b=L8csjDHFJQb/Z9ra8F4yeComBY2mu68MPG3GfpGjcCgSr6hhJI9uX5Kynf3LiU68/iKMK5tusrrU+Qvpb5BxZdEsuno+OqafExtIaFYcrQXzNNI86IzBB9N0GaY0IMGeFAD5jddTUM11zvnfPMkc0TyoCA9wmluFK0QH5xDPWkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147417; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EUzOrDcz1AGLPLWjWXyXaCj3TBotsysZNYHGdl2IwIE=; b=LaccZE3ciK6oACgbKgx+prWZJBUwOnO9uVeF99kfddzZri4ymMZ1o0tsK98Ag67qSttATyyRdAWN5IQMJv5Utt58dcX8I7TUwd5DPlEVn9JCp+9HEvoWnDjDzVC35i2qwv5j6YQTjkuqw7C4XDfmRVZ+aXjKTQ4Vm71L5ClV7uA= 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 172114741735248.71240678867969; Tue, 16 Jul 2024 09:30:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2P-0002bL-IC; Tue, 16 Jul 2024 12:28:25 -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 1sTl1i-0007WI-5Q; Tue, 16 Jul 2024 12:27:45 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl1d-0006eH-6H; Tue, 16 Jul 2024 12:27:40 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-70b3c0a00f2so3564031b3a.3; Tue, 16 Jul 2024 09:27:30 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147249; x=1721752049; darn=nongnu.org; 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=EUzOrDcz1AGLPLWjWXyXaCj3TBotsysZNYHGdl2IwIE=; b=HmaadkDt3OJnZ6PeBjPEXm+pIQqn0EQNPUJ9zXZTWXhHkxgAO5LTimL5BR0oPdJbCE bTY8ih6+fTnJds//XqgTEZ+KkqMBs/RXKbyHCyluViQ0VMdVeCDnRuQo21e8TeCjouG1 y2wmB1/z5pOVLCBrHOtH5BXmZ1vz/PC6Woht+gkKl8hiSrTccu0jFA0WvMpRM7SY8C3Y 6SKTdHqXN+cSm+rBcqObHXCSXvqppOXVQJgqlR1IXax7PQcw9XXr46lhj6STDy5yikzw a4EBDyXQfh07YhdnaRNLp7Ag9MOcWfL0b3TZeRaAcEJSrVpts1FaYpaYsw7xmh0W4oeP WYtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147249; x=1721752049; 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=EUzOrDcz1AGLPLWjWXyXaCj3TBotsysZNYHGdl2IwIE=; b=limZgmeqLjaNzdb7rXm+YwgGJ3kWMHM3J+70kijkATj+tZblJSQocxVQS+TpK9j6WJ 5LFNjJBqe67Z/xRDFsSiKsD7KLidMpt2pzc7HaQ9Mb5qYOoQYdDh4QySa7rfKNLXvTHX b8D+EWBQozsiF7t2WgaNRGCLsLh7agN63zff8ENQeBmz21jYGMBzhOMlew32cBQEfPjH o3V0MCD5JpRTTFcEG5aioaYAXh6WvAzKV9xeTLdsdY1pFjJFAYeVMce/4WWkV8fOHJJG uWdeFYhaaFAqVWn3wECj8YB3F5g/K52pzZhMM8JC/OOjXK99lrspJ7ft0CkgLFzFR+1T xuEQ== X-Forwarded-Encrypted: i=1; AJvYcCW/SwT3JuDp7qmLbHYnQho1ckQ5iAqOGgIHDB5LydSWi8uJdIYZ+v1j0Pk+LaMwRfvNTQysiuqoN8BA/I6dgtx8wev8XfU= X-Gm-Message-State: AOJu0YycQQC830MSQcVQEdVrSHZdqLqo5qhwoiklEm9AQ72Y9Oj5XrEp vPw2sj8V1XgCN1NmHUcEBMuJ8x0D71Mj0yknnwPfDweMDv/6ZXJ79FhLqw== X-Google-Smtp-Source: AGHT+IGisbjoUBY8Bi/ZzYpmwNxJIj1gJ96cZDU2Ndw8B+sWdrDvbw8sz7oAc7HR3TFGAdSgKYOu6Q== X-Received: by 2002:a05:6a20:7f93:b0:1c2:a6ad:d23e with SMTP id adf61e73a8af0-1c3f1256149mr2853498637.30.1721147248836; Tue, 16 Jul 2024 09:27:28 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v3 17/19] ppc/pnv: Add a CPU nmi and resume function Date: Wed, 17 Jul 2024 02:26:13 +1000 Message-ID: <20240716162617.32161-18-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::42f; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42f.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 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: 1721147419064116600 Power CPUs have an execution control facility that can pause, resume, and cause NMIs, among other things. Add a function that will nmi a CPU and resume it if it was paused, in preparation for implementing the control facility. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv.h | 2 ++ hw/ppc/pnv.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index c56d152889..b7858d310d 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -112,6 +112,8 @@ PnvChip *pnv_chip_add_phb(PnvChip *chip, PnvPHB *phb); #define PNV_FDT_ADDR 0x01000000 #define PNV_TIMEBASE_FREQ 512000000ULL =20 +void pnv_cpu_do_nmi_resume(CPUState *cs); + /* * BMC helpers */ diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 08aaac359b..f7580947ed 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2751,11 +2751,23 @@ static void pnv_cpu_do_nmi_on_cpu(CPUState *cs, run= _on_cpu_data arg) */ env->spr[SPR_SRR1] |=3D SRR1_WAKESCOM; } + if (arg.host_int =3D=3D 1) { + cpu_resume(cs); + } +} + +/* + * Send a SRESET (NMI) interrupt to the CPU, and resume execution if it was + * paused. + */ +void pnv_cpu_do_nmi_resume(CPUState *cs) +{ + async_run_on_cpu(cs, pnv_cpu_do_nmi_on_cpu, RUN_ON_CPU_HOST_INT(1)); } =20 static void pnv_cpu_do_nmi(PnvChip *chip, PowerPCCPU *cpu, void *opaque) { - async_run_on_cpu(CPU(cpu), pnv_cpu_do_nmi_on_cpu, RUN_ON_CPU_NULL); + async_run_on_cpu(CPU(cpu), pnv_cpu_do_nmi_on_cpu, RUN_ON_CPU_HOST_INT(= 0)); } =20 static void pnv_nmi(NMIState *n, int cpu_index, Error **errp) --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147495; cv=none; d=zohomail.com; s=zohoarc; b=A2xIQxmiIpiON7l/jTTga1RCWIXryN2CF1wBm+XecfZWGdwoVPJd9utDa+XjIDxNSjAWJ+IYwwTGYaA9bJpgyIM4k92hjyfEsPZ4SYtIBI1FMuRZKPVcH/G+NTWqqiOkypSzxsp0Xd4RUrK3lXTQwvtelp7xWlDRjxt3jQSQ4fs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147495; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=z5TYVL1+Yc8WK0n0GdjxRRRAt3lrb2JlCgvlJVpBsBY=; b=VPTPtAwrCjdjWa8NGe+L3g+kZjIHIn6kg8zYv4Eq2um08eb5AD9Kx5hOjwxXPPJp0Yxb87xlXRR3PxxDpl4qbh453SLA4R9CfhEHQ1uJIyqqOZXmTOpsF6TT7PAWhiJL2j8MAsEPQGRAiwqt7POMCJhTURnDoaMbbObL7SzTiqQ= 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 1721147494994498.04642237553924; Tue, 16 Jul 2024 09:31:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2W-0003mg-3o; Tue, 16 Jul 2024 12:28:32 -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 1sTl1f-0007RW-Np; Tue, 16 Jul 2024 12:27:40 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTl1b-0006eY-CI; Tue, 16 Jul 2024 12:27:38 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-75c3acf90f0so3940938a12.2; Tue, 16 Jul 2024 09:27:33 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147252; x=1721752052; darn=nongnu.org; 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=z5TYVL1+Yc8WK0n0GdjxRRRAt3lrb2JlCgvlJVpBsBY=; b=U/rewGvIOEhlfKwKcCgwqkRsEAJGFWCKX+Wk3VpLs9CQ5vxg+L/wuDipI7a2ze+wXH GUENzLdrfUdTg26AJ/cAIrypJfV6+0UONxXUk8fcbOxy2uWkUUm/EBsNCHE94/BzUDD2 oq3Y3GOTjV2Bw6isZBuZV1RZfdpqE7NjFvJwbB6MESqGAjea/6uUOtyOawquZcKpsu01 avQfvoSSzWgEq5+jUUFSZF2jaCbuCbDRlYmGTCa2MUfVc51eFjKm0GGyx73UyZIXp03O Re2JLBe4bfRuj1KY3KNSh5e1h8HFEzAnyq4nKzem4PL79t4ZPCLtwhBKKpyHyxcoPxk/ bHFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147252; x=1721752052; 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=z5TYVL1+Yc8WK0n0GdjxRRRAt3lrb2JlCgvlJVpBsBY=; b=Dhk9vLuoBRvVShi91Lzu3QRdEtzIrXHaeqGaDgNh1GOVrEk6yMAZZNsxjMaTiYVR3P qMWBPDbN0hYn0z1NUDClvXIl+1DkjUMzT1woER5gNAMsPtsbwTTgdQIsBZAMaySV+nJk VVYE4P7sQXdWxv71/Ff4W4l37fr5ogMdA1hKNwPvFyrTFT+nqq7iz5bjkquZOXEvm/vn ya6knwkvzDhuIg/L5+9yB50GILppNIJbp3HmwJv7xDihf0oeLB7YQeNEtf2EIi1Mxoqe 8RMVQfLfrz9Ifp0CDRXTYoeGeeYvFCE4mkCj8N393gurdtWP8Cvb7OnocSA5HGgH7gdR O7Hw== X-Forwarded-Encrypted: i=1; AJvYcCXPVzj4Zco5zVTiMEEddWO8RpUE3WPs1d1bLAGQINyVPI1x2KwrODZOtgT54FQqENgkTtW1bxhYECDUrmqQfvCMu+SN/SU= X-Gm-Message-State: AOJu0YxILT8Q2Z/mcWY+VvnLbBqfis8HUcp8D6JK5K5DwxrOlPpfy8Ov ha3bIH/atdBHnwGLeT0Gez7Snqb1R8OZGT9pNESmzjvQbOAEqev+S9yNMQ== X-Google-Smtp-Source: AGHT+IEkZ9iFMbJ5PJ8j5nwresaxAmpwusHF6DXjVs1/uFzea2fWFOoGmx/SZG0oN8soxJDHUQmi8g== X-Received: by 2002:a05:6a21:3947:b0:1c0:e9dd:11b8 with SMTP id adf61e73a8af0-1c3f12399e1mr2999752637.28.1721147252358; Tue, 16 Jul 2024 09:27:32 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH v3 18/19] ppc/pnv: Implement POWER10 PC xscom registers for direct controls Date: Wed, 17 Jul 2024 02:26:14 +1000 Message-ID: <20240716162617.32161-19-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::52b; envelope-from=npiggin@gmail.com; helo=mail-pg1-x52b.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 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: 1721147495416116600 Content-Type: text/plain; charset="utf-8" The PC unit in the processor core contains xscom registers that provide low level status and control of the CPU. This implements "direct controls", sufficient for skiboot firmware, which uses it to send NMI IPIs between CPUs. POWER10 is sufficiently different from POWER9 (particularly with respect to QME and special wakeup) that it is not trivial to implement POWER9 support by reusing the code. Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv_core.h | 3 ++ hw/ppc/pnv_core.c | 89 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h index c8784777a4..1de79a818e 100644 --- a/include/hw/ppc/pnv_core.h +++ b/include/hw/ppc/pnv_core.h @@ -109,6 +109,9 @@ OBJECT_DECLARE_TYPE(PnvQuad, PnvQuadClass, PNV_QUAD) struct PnvQuad { DeviceState parent_obj; =20 + bool special_wakeup_done; + bool special_wakeup[4]; + uint32_t quad_id; MemoryRegion xscom_regs; MemoryRegion xscom_qme_regs; diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 1783795b23..8ed1cfe8a2 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -185,16 +185,40 @@ static const MemoryRegionOps pnv_core_power9_xscom_op= s =3D { */ =20 #define PNV10_XSCOM_EC_CORE_THREAD_STATE 0x412 +#define PNV10_XSCOM_EC_CORE_THREAD_INFO 0x413 +#define PNV10_XSCOM_EC_CORE_DIRECT_CONTROLS 0x449 +#define PNV10_XSCOM_EC_CORE_RAS_STATUS 0x454 =20 static uint64_t pnv_core_power10_xscom_read(void *opaque, hwaddr addr, unsigned int width) { + PnvCore *pc =3D PNV_CORE(opaque); + int nr_threads =3D CPU_CORE(pc)->nr_threads; + int i; uint32_t offset =3D addr >> 3; uint64_t val =3D 0; =20 switch (offset) { case PNV10_XSCOM_EC_CORE_THREAD_STATE: - val =3D 0; + for (i =3D 0; i < nr_threads; i++) { + PowerPCCPU *cpu =3D pc->threads[i]; + CPUState *cs =3D CPU(cpu); + + if (cs->halted) { + val |=3D PPC_BIT(56 + i); + } + } + break; + case PNV10_XSCOM_EC_CORE_THREAD_INFO: + break; + case PNV10_XSCOM_EC_CORE_RAS_STATUS: + for (i =3D 0; i < nr_threads; i++) { + PowerPCCPU *cpu =3D pc->threads[i]; + CPUState *cs =3D CPU(cpu); + if (cs->stopped) { + val |=3D PPC_BIT(0 + 8 * i) | PPC_BIT(1 + 8 * i); + } + } break; default: qemu_log_mask(LOG_UNIMP, "%s: unimp read 0x%08x\n", __func__, @@ -207,9 +231,46 @@ static uint64_t pnv_core_power10_xscom_read(void *opaq= ue, hwaddr addr, static void pnv_core_power10_xscom_write(void *opaque, hwaddr addr, uint64_t val, unsigned int width) { + PnvCore *pc =3D PNV_CORE(opaque); + int nr_threads =3D CPU_CORE(pc)->nr_threads; + int i; uint32_t offset =3D addr >> 3; =20 switch (offset) { + case PNV10_XSCOM_EC_CORE_DIRECT_CONTROLS: + for (i =3D 0; i < nr_threads; i++) { + PowerPCCPU *cpu =3D pc->threads[i]; + CPUState *cs =3D CPU(cpu); + + if (val & PPC_BIT(7 + 8 * i)) { /* stop */ + val &=3D ~PPC_BIT(7 + 8 * i); + cpu_pause(cs); + } + if (val & PPC_BIT(6 + 8 * i)) { /* start */ + val &=3D ~PPC_BIT(6 + 8 * i); + cpu_resume(cs); + } + if (val & PPC_BIT(4 + 8 * i)) { /* sreset */ + val &=3D ~PPC_BIT(4 + 8 * i); + pnv_cpu_do_nmi_resume(cs); + } + if (val & PPC_BIT(3 + 8 * i)) { /* clear maint */ + /* + * Hardware has very particular cases for where clear maint + * must be used and where start must be used to resume a + * thread. These are not modelled exactly, just treat + * this and start the same. + */ + val &=3D ~PPC_BIT(3 + 8 * i); + cpu_resume(cs); + } + } + if (val) { + qemu_log_mask(LOG_UNIMP, "%s: unimp bits in DIRECT_CONTROLS " + "0x%016lx\n", __func__, val); + } + break; + default: qemu_log_mask(LOG_UNIMP, "%s: unimp write 0x%08x\n", __func__, offset); @@ -526,6 +587,7 @@ static const MemoryRegionOps pnv_quad_power10_xscom_ops= =3D { static uint64_t pnv_qme_power10_xscom_read(void *opaque, hwaddr addr, unsigned int width) { + PnvQuad *eq =3D PNV_QUAD(opaque); uint32_t offset =3D addr >> 3; uint64_t val =3D -1; =20 @@ -533,10 +595,14 @@ static uint64_t pnv_qme_power10_xscom_read(void *opaq= ue, hwaddr addr, * Forth nibble selects the core within a quad, mask it to process read * for any core. */ - switch (offset & ~0xf000) { - case P10_QME_SPWU_HYP: + switch (offset & ~PPC_BITMASK32(16, 19)) { case P10_QME_SSH_HYP: - return 0; + val =3D 0; + if (eq->special_wakeup_done) { + val |=3D PPC_BIT(1); /* SPWU DONE */ + val |=3D PPC_BIT(4); /* SSH SPWU DONE */ + } + break; default: qemu_log_mask(LOG_UNIMP, "%s: unimp read 0x%08x\n", __func__, offset); @@ -548,9 +614,22 @@ static uint64_t pnv_qme_power10_xscom_read(void *opaqu= e, hwaddr addr, static void pnv_qme_power10_xscom_write(void *opaque, hwaddr addr, uint64_t val, unsigned int width) { + PnvQuad *eq =3D PNV_QUAD(opaque); uint32_t offset =3D addr >> 3; + bool set; + int i; =20 - switch (offset) { + switch (offset & ~PPC_BITMASK32(16, 19)) { + case P10_QME_SPWU_HYP: + set =3D !!(val & PPC_BIT(0)); + eq->special_wakeup_done =3D set; + for (i =3D 0; i < 4; i++) { + /* These bits select cores in the quad */ + if (offset & PPC_BIT32(16 + i)) { + eq->special_wakeup[i] =3D set; + } + } + break; default: qemu_log_mask(LOG_UNIMP, "%s: unimp write 0x%08x\n", __func__, offset); --=20 2.45.1 From nobody Fri Oct 18 06:20:31 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=1721147377; cv=none; d=zohomail.com; s=zohoarc; b=XAjKXNC4zesXmmt/MpscrG96Wf6IcHssmGTc0NEoNNesRHyKWHO7sGk2YzBA2eOIqJYkwd86VbJv2Y6MZkSpfqyyoGhN5APO33rvJUU2KjT0KUthJimPnqxuzFwiIOPYemHeh89T3AwI2AVFlabg2znb+g5ToNyjfhFwE1inC8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721147377; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PgE2sde4R6CqNdVv3iM8qfaneuklXpZ8D0G1bOi+23U=; b=FWI4w7kSQk1tmIqVv8M/jAyC/LsJV8ne0RgYB0oVk/3D2s+vmMMFdRROK/JqvyeaH3Pma7aanHE67tL+IXjsYa0zT0bsFMB0bWbkbma5ftVicFMPzwWoZC2ts9fx+ov5ZbPDm/97JLXZ/58k6RBYixA0T6dKFbp6X8LgZrQ2VO0= 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 1721147376958101.8010149396215; Tue, 16 Jul 2024 09:29:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTl2Q-0002pl-Oo; Tue, 16 Jul 2024 12:28:26 -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 1sTl1v-0008Jm-UK; Tue, 16 Jul 2024 12:27:57 -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 1sTl1f-0006fF-O9; Tue, 16 Jul 2024 12:27:55 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-70af8062039so3931576b3a.0; Tue, 16 Jul 2024 09:27:37 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eca86d6sm6722161b3a.179.2024.07.16.09.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 09:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721147256; x=1721752056; darn=nongnu.org; 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=PgE2sde4R6CqNdVv3iM8qfaneuklXpZ8D0G1bOi+23U=; b=UrjXHsjIAQKuA4WetFKpeQdL1/tqNEdOpefYa4TEbz7FjNQ2nvZetdzFlvRWcD6g27 pkMSFx/PPqs0Krr8wfmG9G8vP1IxBcyTtMPaLrKDi7DVAnys7Y4ckNe/vfzuGx1c6ztT VvsHFZenbosQK6Mpxy0H0tSBzEQNtNUKuVEO+3p6razYUJ4u3qcv2yGD781oovK6ifAW zMY+ht4yWIIjBIhbW6kn3uQz2gKUxT7p9M4tqmqC1MCrobFoVaw9K0hosX1tsRRnig78 YhZDpVo4KXfopqKy7paLaj5Qi3Oz+oo8bgNlRETqnpc0pqgrCwmkiYqUapWnxuAoxQXa H2cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721147256; x=1721752056; 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=PgE2sde4R6CqNdVv3iM8qfaneuklXpZ8D0G1bOi+23U=; b=DIAnyBhaH+5S5D9Jso9k6WfPUS8aA0OuMn/nmKPlW8jR3HhmTkRF3vFxnWMp9XS6nx T1GVJJSj6W7fBxyii0T0yxt8XSvTxDp/j8u310iebcKcMoQFsk1n8w/vLOEPH9hcdY32 /OjfDIzkKO/0FdthHjiJKS56V08z6SObaL8Dmk5OShrIQHEcrjb0bgo/1cABrONGI9jr 8W6FvgE1OEP6lLEIX/AxTf+revbqfxQAOdN3v5dXgCwgiDKyhULwwJDMXj2uxxoFQ3SX BlF3ZGrS58RZlWevvSWZFXa0U9GkZq1H4IUU4CQ+H9PjVoXbDHWQv7nxSkIyEFpSyEKo Smxw== X-Forwarded-Encrypted: i=1; AJvYcCWSXUUj7ulFpMBVjT+egfopWUOlKLbLDPsiO+vxYTohqg3JW9BzRZNGVmGKsV0dWL6MOw6bfYKimXywav8fHw+JUu1hU9Y= X-Gm-Message-State: AOJu0YwcCK+Nx1rQqszHkgX6N+PAHkaXVXlhQM3xl+KeR8Qx0HTJmr4J MiPFxX+/y5tT9bo/55+sMcuJVJwO5vkdVfnUvBedLZcx8cFClZ6GBA+1cw== X-Google-Smtp-Source: AGHT+IG2H76ygeVa+TgOBNDxm/aehEmaW3GnLp/sYNSRhgEQfgCATSkX5vVZ3PFSuYBBUx4EZcPjZg== X-Received: by 2002:a05:6a00:3d52:b0:706:375e:220e with SMTP id d2e1a72fcca58-70c1fbd4f2cmr3577352b3a.8.1721147256005; Tue, 16 Jul 2024 09:27:36 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH v3 19/19] ppc/pnv: Add an LPAR per core machine option Date: Wed, 17 Jul 2024 02:26:15 +1000 Message-ID: <20240716162617.32161-20-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716162617.32161-1-npiggin@gmail.com> References: <20240716162617.32161-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::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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1721147378873116600 Content-Type: text/plain; charset="utf-8" Recent POWER CPUs can operate in "LPAR per core" or "LPAR per thread" modes. In per-core mode, some SPRs and IPI doorbells are shared between threads in a core. In per-thread mode, supervisor and user state is not shared between threads. OpenPOWER systems after POWER8 use LPAR per thread mode, and it is required for KVM. Enterprise systems use LPAR per core mode, as they partition the machine by core. Implement a lpar-per-core machine option for powernv machines. This is fixed true for POWER8 machines, and defaults off for P9 and P10. With this change, powernv8 SMT now works sufficiently to run Linux, with a single socket. Multi-threaded KVM guests still have problems, as does multi-socket Linux boot. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv.h | 2 ++ include/hw/ppc/pnv_chip.h | 1 + include/hw/ppc/pnv_core.h | 1 + hw/ppc/pnv.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/ppc/pnv_core.c | 8 ++++++++ target/ppc/cpu_init.c | 3 ++- 6 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index b7858d310d..fcb6699150 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -77,6 +77,7 @@ struct PnvMachineClass { const char *compat; int compat_size; int max_smt_threads; + bool has_lpar_per_thread; bool quirk_tb_big_core; =20 void (*dt_power_mgt)(PnvMachineState *pnv, void *fdt); @@ -104,6 +105,7 @@ struct PnvMachineState { hwaddr fw_load_addr; =20 bool big_core; + bool lpar_per_core; }; =20 PnvChip *pnv_get_chip(PnvMachineState *pnv, uint32_t chip_id); diff --git a/include/hw/ppc/pnv_chip.h b/include/hw/ppc/pnv_chip.h index 69d8273efe..ee1649babc 100644 --- a/include/hw/ppc/pnv_chip.h +++ b/include/hw/ppc/pnv_chip.h @@ -28,6 +28,7 @@ struct PnvChip { uint64_t ram_size; =20 bool big_core; + bool lpar_per_core; uint32_t nr_cores; uint32_t nr_threads; uint64_t cores_mask; diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h index 1de79a818e..d8afb4f95f 100644 --- a/include/hw/ppc/pnv_core.h +++ b/include/hw/ppc/pnv_core.h @@ -57,6 +57,7 @@ struct PnvCore { /*< public >*/ PowerPCCPU **threads; bool big_core; + bool lpar_per_core; uint32_t pir; uint32_t hwid; uint64_t hrmor; diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index f7580947ed..8d24fc2a45 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1026,6 +1026,11 @@ static void pnv_init(MachineState *machine) exit(1); } =20 + /* Set lpar-per-core mode if lpar-per-thread is not supported */ + if (!pmc->has_lpar_per_thread) { + pnv->lpar_per_core =3D true; + } + pnv->num_chips =3D machine->smp.max_cpus / (machine->smp.cores * machine->smp.threads= ); =20 @@ -1102,6 +1107,8 @@ static void pnv_init(MachineState *machine) &error_fatal); object_property_set_bool(chip, "big-core", pnv->big_core, &error_fatal); + object_property_set_bool(chip, "lpar-per-core", pnv->lpar_per_core, + &error_fatal); /* * The POWER8 machine use the XICS interrupt interface. * Propagate the XICS fabric to the chip and its controllers. @@ -2338,6 +2345,8 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) &error_fatal); object_property_set_bool(OBJECT(pnv_core), "quirk-tb-big-core", pmc->quirk_tb_big_core, &error_fatal); + object_property_set_bool(OBJECT(pnv_core), "lpar-per-core", + chip->lpar_per_core, &error_fatal); object_property_set_link(OBJECT(pnv_core), "chip", OBJECT(chip), &error_abort); =20 @@ -2373,6 +2382,7 @@ static Property pnv_chip_properties[] =3D { DEFINE_PROP_UINT64("cores-mask", PnvChip, cores_mask, 0x0), DEFINE_PROP_UINT32("nr-threads", PnvChip, nr_threads, 1), DEFINE_PROP_BOOL("big-core", PnvChip, big_core, false), + DEFINE_PROP_BOOL("lpar-per-core", PnvChip, lpar_per_core, false), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -2593,6 +2603,18 @@ static void pnv_machine_set_big_core(Object *obj, bo= ol value, Error **errp) pnv->big_core =3D value; } =20 +static bool pnv_machine_get_lpar_per_core(Object *obj, Error **errp) +{ + PnvMachineState *pnv =3D PNV_MACHINE(obj); + return pnv->lpar_per_core; +} + +static void pnv_machine_set_lpar_per_core(Object *obj, bool value, Error *= *errp) +{ + PnvMachineState *pnv =3D PNV_MACHINE(obj); + pnv->lpar_per_core =3D value; +} + static bool pnv_machine_get_hb(Object *obj, Error **errp) { PnvMachineState *pnv =3D PNV_MACHINE(obj); @@ -2632,6 +2654,8 @@ static void pnv_machine_power8_class_init(ObjectClass= *oc, void *data) pmc->compat =3D compat; pmc->compat_size =3D sizeof(compat); pmc->max_smt_threads =3D 8; + /* POWER8 is always lpar-per-core mode */ + pmc->has_lpar_per_thread =3D false; =20 machine_class_allow_dynamic_sysbus_dev(mc, TYPE_PNV_PHB); } @@ -2657,6 +2681,7 @@ static void pnv_machine_power9_class_init(ObjectClass= *oc, void *data) pmc->compat =3D compat; pmc->compat_size =3D sizeof(compat); pmc->max_smt_threads =3D 4; + pmc->has_lpar_per_thread =3D true; pmc->dt_power_mgt =3D pnv_dt_power_mgt; =20 machine_class_allow_dynamic_sysbus_dev(mc, TYPE_PNV_PHB); @@ -2666,6 +2691,12 @@ static void pnv_machine_power9_class_init(ObjectClas= s *oc, void *data) pnv_machine_set_big_core); object_class_property_set_description(oc, "big-core", "Use big-core (aka fused-core) mode"); + + object_class_property_add_bool(oc, "lpar-per-core", + pnv_machine_get_lpar_per_core, + pnv_machine_set_lpar_per_core); + object_class_property_set_description(oc, "lpar-per-core", + "Use 1 LPAR per core mode"); } =20 static void pnv_machine_p10_common_class_init(ObjectClass *oc, void *data) @@ -2688,6 +2719,7 @@ static void pnv_machine_p10_common_class_init(ObjectC= lass *oc, void *data) pmc->compat =3D compat; pmc->compat_size =3D sizeof(compat); pmc->max_smt_threads =3D 4; + pmc->has_lpar_per_thread =3D true; pmc->quirk_tb_big_core =3D true; pmc->dt_power_mgt =3D pnv_dt_power_mgt; =20 @@ -2713,6 +2745,12 @@ static void pnv_machine_power10_class_init(ObjectCla= ss *oc, void *data) pnv_machine_set_big_core); object_class_property_set_description(oc, "big-core", "Use big-core (aka fused-core) mode"); + + object_class_property_add_bool(oc, "lpar-per-core", + pnv_machine_get_lpar_per_core, + pnv_machine_set_lpar_per_core); + object_class_property_set_description(oc, "lpar-per-core", + "Use 1 LPAR per core mode"); } =20 static void pnv_machine_p10_rainier_class_init(ObjectClass *oc, void *data) diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 8ed1cfe8a2..0384122054 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -208,6 +208,9 @@ static uint64_t pnv_core_power10_xscom_read(void *opaqu= e, hwaddr addr, val |=3D PPC_BIT(56 + i); } } + if (pc->lpar_per_core) { + val |=3D PPC_BIT(62); + } break; case PNV10_XSCOM_EC_CORE_THREAD_INFO: break; @@ -321,6 +324,10 @@ static void pnv_core_cpu_realize(PnvCore *pc, PowerPCC= PU *cpu, Error **errp, env->core_index =3D core_hwid; } =20 + if (pc->lpar_per_core) { + cpu_ppc_set_1lpar(cpu); + } + /* Set time-base frequency to 512 MHz */ cpu_ppc_tb_init(env, PNV_TIMEBASE_FREQ); } @@ -427,6 +434,7 @@ static Property pnv_core_properties[] =3D { DEFINE_PROP_BOOL("big-core", PnvCore, big_core, false), DEFINE_PROP_BOOL("quirk-tb-big-core", PnvCore, tod_state.big_core_quir= k, false), + DEFINE_PROP_BOOL("lpar-per-core", PnvCore, lpar_per_core, false), DEFINE_PROP_LINK("chip", PnvCore, chip, TYPE_PNV_CHIP, PnvChip *), DEFINE_PROP_END_OF_LIST(), }; diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 81dd4e1a7a..4ba7f54510 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6803,7 +6803,8 @@ void cpu_ppc_set_1lpar(PowerPCCPU *cpu) =20 /* * pseries SMT means "LPAR per core" mode, e.g., msgsndp is usable - * between threads. + * between threads. powernv be in either mode, and it mostly affects + * supervisor visible registers and instructions. */ if (env->flags & POWERPC_FLAG_SMT) { env->flags |=3D POWERPC_FLAG_SMT_1LPAR; --=20 2.45.1