From nobody Sun Nov 24 18:23:39 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=1720785881; cv=none; d=zohomail.com; s=zohoarc; b=LXwtJFsNZy/Hlj3abPPjcGkijYfjoWXWrAQGD2aRR/UWWmEIKC4vAVp5oM6+Ubxh9md/fodXndy5H7ZryWffVWVc2Xgpn/VsUSwmvMI4+oqi2RjvLzchTJiZ58wsivWjjFnGa90WPx5pKSloA+hEM3D1yp8sdXvRbI03zaa3Ajw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785881; 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=gHZXC+jF29amtF15KumpSDuF+B1EAf1/u+38z0QB5h8ct2m6tsSFiOtV3oTO+rViNft9lghDKIwV1NHMfHyQr56qcI5zV8jeOrqk6RfLfavwpK4cfXJZn0Vz+oqAlNUBMu6bBKN8e6NsvRhIeY2Nqf4x5ikVws4RTtsiaLA3wF4= 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 1720785881461785.3952272760166; Fri, 12 Jul 2024 05:04:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0F-0006ND-E2; Fri, 12 Jul 2024 08:03:55 -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 1sSEzV-0003pV-H9; Fri, 12 Jul 2024 08:03:17 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSEzR-0005Pw-M6; Fri, 12 Jul 2024 08:03:08 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-70b13791a5eso1645280b3a.1; Fri, 12 Jul 2024 05:03:02 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785781; x=1721390581; 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=WoR4dy7BQKu8ouHzjI4/M7wJsfUzqiu0H2MF6w5lGdFDZ+X5SWg+jT6pBokvUH955K 4NamA/JDk3EUhNfkGUJhqo0zA1JOdC9bkKnDOeIkqCcNPwDdfNsczMI7fUdyl86TeCRX xGG8gA0i5yZl+ivFsXBJFWBGs143d2v8qrkQws7e4+1Ep8qgkKY6gZXGwRCXVwN1Ov2U 6NhOg2JIQYuGWp8Bxf0Vbm8uB5n9gb5okxdwneWFXKYX8UfU0NJbHS5vB26NdmKQv/ag 9DFhwmTjY3Fqxxk0h1kgyIzgqp2a2FvkH5moNEZBo2iG9wniryoIvTjApPnb80au+V32 LTKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785781; x=1721390581; 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=porAnHctY9Yufivp68WNUt5g4x3VOW5lqlmGWL+TMuXkkzUfEs9fM/gi4QDO4er/bx MCg5Zgl6iotOTIzPvoy+F86/KmB7koxr61ZmrwGBQl0MUqCRZuRTde3YXRWh1ghekJpT /jseDf26qPET++DVQBlrpvOPGFdbqFofJtYn4ONs1pvryHLqgXz81I4/EMMVrpQlzjK3 N/KNwOjj0uqDXORf7V0HrwB/TmTsX929v0gW6vIs7cdkkhMrdbGYJ7sIp08fHx9htqwQ koh5xB/1a/5A9j41RwsE4ByVJ0TbfrlcMV8iqpYqFpcmAsG4g6qA+vNEkq4ZszLGbqWQ B14A== X-Forwarded-Encrypted: i=1; AJvYcCWOkOHtIQR9gk6G08n+ndGj5Kd8zphyIlPHjYFO0MXrlLBr3O07O08SyNFhv3x14fJ/x1r6VQpUX/GKbR8KQSduQFSQzY0= X-Gm-Message-State: AOJu0Yx1c/YhjA9vDK8WPNwWjLpJmdBWoYvZaMX2H3qFSOK/S2N57jKk Q8yXYB7ErhkYoI+4hboXtuHIlCPOAAttlThDfCCvvP7Dh7focM4j/W2WgQ== X-Google-Smtp-Source: AGHT+IEUD8WdJRMjWSCBr5swBEJWeXVdnX6fpN3tn4GfB6QbIWkXrEX8ZLSXiPJR+KunESwpOk49Sg== X-Received: by 2002:a05:6a00:2e04:b0:702:6f45:effc with SMTP id d2e1a72fcca58-70b4357d653mr14660357b3a.20.1720785780533; Fri, 12 Jul 2024 05:03:00 -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 v2 01/19] target/ppc: Fix msgsnd for POWER8 Date: Fri, 12 Jul 2024 22:02:28 +1000 Message-ID: <20240712120247.477133-2-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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::430; envelope-from=npiggin@gmail.com; helo=mail-pf1-x430.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: 1720785882208116600 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 --- 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 Sun Nov 24 18:23:39 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=1720785859; cv=none; d=zohomail.com; s=zohoarc; b=nlg7VTK8XRwpKFz7lk5K4OTkRXOkxEAvOODf2pC2ymFeZx58055+1vTMfLAXUPBs1g7GLr9n7m4rsEzXzKsvpmMigNle/ZnQFwIOlNAoMCbmgYHot9sjFq++0gwRQx6N/7BWvJitBixQ6jhRoPWYR3JzHAnBHkdAZQ0HcmMn8YA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785859; 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=E3Liy3Uwr+xJw+3HoLNZcuecNSpU0Twhg9JqoQ16BmRusm4+mUbd66oLsOutNEkydKR86G38+mSdiWZpKwrWwP7J8RWaUWcAOH74IqPZ/1K3JeyVhweXTLomX2RsY287PTXNY9RsF1oaj8qEF9Yoqp2MWEIYPfcYgNVfhi1xQHA= 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 1720785859501665.1740988508963; Fri, 12 Jul 2024 05:04:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0C-00063k-Bi; Fri, 12 Jul 2024 08:03:52 -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 1sSEzX-0003yf-WD; Fri, 12 Jul 2024 08:03:18 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSEzV-0005XT-41; Fri, 12 Jul 2024 08:03:11 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-70b12572bd8so1634210b3a.2; Fri, 12 Jul 2024 05:03:07 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785785; x=1721390585; 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=kPf1moXPF/Sb0aJ9RGI8GGJHQaIyn1+zfzZpNNGwFY5lop6x5JawS6GrgM1/V6AFqC RZvmvmYsKtNqire1tjzsFE5Ko0ZlqI4SLSLuG6RaDL8PHto4IGBv6RHLBbB941TBz0lL PZ8ufGpMu7J0n//34DvdNXh0aeMnrU1Nwp7AeEQn/8LPvsa47um+VguEV2PUwFNAPttO qtvYAiDC/W3rlUpA2C3KzZf+eoLcKh6inrfxgYwj2fJUtURUUFHNsxhOariKoKKmrOlm HG60zYBg1JlCpmH/tAoQiNN3AZdHmLza0C1RPWPJqKsFl/ZDRvcxeXyTDRdmChO9HT0F HKwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785785; x=1721390585; 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=lcxZW42ejIksWecme3MbgsuZZnWHLGYFSQuX9Q2bxeAUgvY24yqnH/ZYeMIaH5hI4X AWL2GTFEXC2+GWGoYR0gKE3Ka9BEe51PBavBmYlwHyKLFCuc0yi2mhW/nPQfPOP/ak+T 9Nvk2bsHLAbM9qeceiyOkw0h3XIwWsmEdWVR9+vZqdAeHsPQ2ixnIDKmPhQWwtWPYwEN NkzS1Hb/BKMQngwcUBIAM+zm/S47VWJHh90njNmuysL8aa4PfrcgL7Nvf+pmXBDS4iZx T1jLZe0dxVTDTXfzaD83mo3QTRueVyAMOEFigIPR/Ojt+VVpwkNo8sZF+jUr+n+Wp7ua 5lTA== X-Forwarded-Encrypted: i=1; AJvYcCV/2E+sIIEw+lwoo98ZJhc1RdJBzddfGQP9oU3LXBFaWBoAgGh5mRUXKW47qUXRevxJDAOXyQUC4QO60gh68WPJRL3ZEeA= X-Gm-Message-State: AOJu0YyRPjKZioeBNeI3pYspXxOiyiP/tV/vg8pnhbqecFgVbL+aYq4F uIfCFR3Dp3/53tcqtroN7H2VD/KqIvMwf5/PwFHMa/26MVWLLUbtoxDviQ== X-Google-Smtp-Source: AGHT+IGI3nnvb3EbXrNLpWQRoWYbQEL+ranD1mZKz4/grlMRKbZGaFWg5KnmRzpzNc/vqUn/g1gwmA== X-Received: by 2002:a05:6a00:b45:b0:705:a450:a9a2 with SMTP id d2e1a72fcca58-70b435561ebmr13471753b3a.13.1720785784997; Fri, 12 Jul 2024 05:03:04 -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 v2 02/19] ppc/pnv: Add pointer from PnvCPUState to PnvCore Date: Fri, 12 Jul 2024 22:02:29 +1000 Message-ID: <20240712120247.477133-3-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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::435; envelope-from=npiggin@gmail.com; helo=mail-pf1-x435.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: 1720785860096116600 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 Sun Nov 24 18:23:39 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=1720785859; cv=none; d=zohomail.com; s=zohoarc; b=eBEvJrgkBUpuaq95pwgg8WeK7abgPNMUPgL+QDprUyp+ZMs2rTQNYJRbUPZ+pLjT4tshhakVS3Kf6BE+ZcP6tR/BKSuWNX6/vtbIE77g5zTQ4fPlufxeTQtILDglgEzy4Y7oqmchg4gWt8bShZQY+cl3PUnwTsVeh3NqVCXn3Yk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785859; 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=m8H6yzBF7/442A7DKwjIZyVO3fuNXQ3t3bicrI2YGEvPxt8xK2qfsuY6PL9vWEDJN5RDJMWwfBynnGN5WSY/P68Q09ZBCNBTpfs5rz9+J1GqLvHp0sKhHUYKdas0iaGvxm8kFG6+xDzRJ1eYwAPwU9pwo04cPFt3n1fmKHEplX0= 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 1720785859558767.3435725900841; Fri, 12 Jul 2024 05:04:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0A-0005nn-0L; Fri, 12 Jul 2024 08:03:50 -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 1sSEzZ-00046Q-Tu; Fri, 12 Jul 2024 08:03:19 -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 1sSEzX-0005Y9-2V; Fri, 12 Jul 2024 08:03:13 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-70b4a8a5587so1574051b3a.2; Fri, 12 Jul 2024 05:03:10 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785789; x=1721390589; 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=W5O25JqMU1IU+TZ2Khh1Wp1cnNIETLV3WMbPbr7g6aFeCsatAfZ5CuvhwS+olhwKIo s/tRtQsCQYYC8nlxf7eHLbTZRCARnxn7Hpu1ex7+KuCRlFdOZLNVdZxxJjWDpvMkahu5 QhSbsv189GMU7lIUbgpXdkgSMjjA9vi97sENVv4EadyGN5FLT4bPk0zB9Bdr2kkfe6N5 uve1Ke8bGzqdHRoa7gZ1QBbESYob7liUtCuc08+G0lHgNLWpWB2flcejhGdRDhNU1+IK Es6+Lq3u4VncVSRhipJw5/P8MFPWbNHKmoUp6Kfq0hRnmSiQ2HYQ5A+bYpl8sN4e8aaJ NTEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785789; x=1721390589; 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=XQaEmNZVq85jSM7OxiwYycOzqGS2uPpT5enPtrr6ORphPaik0tx9PjzI6AtxpynNOI SAtzVW/VQ1uNNE/ahee2jOys4zIgU7qyPyBoJPJy/dpuAfwiH6e8Ez5/NnAXZWyz1PmW tRBtLawVbx5LVTThuIsjZuSi35MgmsGau9R1Yx27rY9DR9gNA7vpkPipQYW6UjWIB4+D wVH+1gKzmaq1cSXjwL8N7tnWnUlbSCMYDJi7M173fFcmTmRBcoyXhypt1E3RvEc7sT2/ fE16+KUyAGE3kvh3NdAY3S97JCuKdZ12qOA3VoeDhUxpkm0cBVWLnTmzjbVrPEY4pwdL ErTA== X-Forwarded-Encrypted: i=1; AJvYcCXcxGLUTc6Rr0rqi1oMQRxqXLdMNpsbQcRMsEFunmnFI9CXOc9s71OhRfBVx5BeomjkeLw9oFUnblJmX7iniUedC8KZzII= X-Gm-Message-State: AOJu0YxYQO4Li57o+ynulR98dtogpdDgotxNPbale0n8KVDs/vmbmhto SloAqPH5JpwTNWtj752Tn2Aw3tUkOF/ELu6y0HOsUJsUMD1br/vnI8YK+w== X-Google-Smtp-Source: AGHT+IGWehJXEtadVuDd7H2un85E7DLRu/dplEyRJUV/v42b5pfOfGdXZOo0Ks6mdDti/2d1boXTow== X-Received: by 2002:a05:6a20:d493:b0:1bf:13f6:7220 with SMTP id adf61e73a8af0-1c2984e1289mr11664591637.56.1720785788821; Fri, 12 Jul 2024 05:03:08 -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 v2 03/19] ppc/pnv: Move timebase state into PnvCore Date: Fri, 12 Jul 2024 22:02:30 +1000 Message-ID: <20240712120247.477133-4-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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::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: 1720785860171116600 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 Sun Nov 24 18:23:39 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=1720785840; cv=none; d=zohomail.com; s=zohoarc; b=K3x1aGy+TxLz7nEJ1snlnlighqodO/a66nI8XXzZtLSDmM+gKSE5LjjzSnlpxjnHQj2+VU548S+h2unRIwD54MNE7Yu5ZKZKrStrvEGe9rsHXcA+atG9ofJp+TZ1hGkBhQxz7FrVOhxelkFox3PL/0aJ+P0jfczpuAwn9KLtc/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785840; 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=gHM/nPflchX6Ww/kaUOMdMxAkJw9BmNXxxMHFbe8gpNz84qT7NmqROEI9/rima30a5eQVC3jv4B4A8CaxVHqs4XKc5Suz58Hz4NsXWe//i9ej8mlNvfwRd5ihTrxNnfD2sh92e8XhWnYolByzR8wSsLNdqFKf+OYHdE2T83sIe4= 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 1720785840100281.24153325853956; Fri, 12 Jul 2024 05:04:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0C-00068Q-J0; Fri, 12 Jul 2024 08:03:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sSEzf-0004Vt-DI; Fri, 12 Jul 2024 08:03:29 -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 1sSEzc-0005Yx-8j; Fri, 12 Jul 2024 08:03:19 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-70af5fbf0d5so1282350b3a.1; Fri, 12 Jul 2024 05:03:14 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785793; x=1721390593; 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=BbhhmjpLVHbGGYwI54due3T5iM8wdU1fJJ+hBwoIABKcPOwfxOuNL+w43BPfFMdcKC U3PCE+XXnix2vcAZGo5D/VMCy/cilRGODiT/WAx64mjyB+IHog5g4dD/H9+9zfgSbDSO zto8FJLkO7eXfr+5V70wQ9KrCBgsMtKx92G2Iug0LldWe6f17NodbvCdN2m8y1ySxj2B iQRbGutxE8aYz5SO8Q02aZX3qcydyhpBlHfhlvvlWQoXWcwUJinZdl5jC5PuRb57FtAu olNujwiCSMj9mK3abZdxhcxy0uACdd8HwwaJOfdCR2P4t+7a69eIc/JRyljv68Gby1PF JwRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785793; x=1721390593; 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=Gi3yBKNzdD+3uUojVa1Fq7vpjxiIKfeJV7LdGWDZbR4HHJj/Vfl/3uGcSqS6bsyOap 5Ety1YbQBOlSVeXwR0mK61FcxWnkN7erXH2+56eOvK5p1FFX5hR/xDD1EMU+5CN9sE+Y I1xqX9k8oXOKBf0rvWda1fHwjYitSlfFBhSi3FlHOE1iX0Ym5OtwZxBpsg3I6byeAZr7 igkR6EVrS8X4TIE1lHy4O767sYUvKpygRj4YYEr4fgN1XDQdgW25C39x7H0t7/dM7ukA ploqMtMthrR5PPme2GENT2+5JovDPzR1ez6sSxgjo83UADi+T7bAVqvCQsXkoVkMHwsE ANMA== X-Forwarded-Encrypted: i=1; AJvYcCXdyb5n6hMBkTZLThorAwWFlygK+NXdqmzQ6N7/qx8W9Om4QDIQl3sQFLYEoycoYx6tvAMpJSD080rxIFoS5iFUcslIrqI= X-Gm-Message-State: AOJu0YxQsfw9CEWLp4zKnB9tdwmsgELwfa3ZLnw6C0KLuux4SJ5UmrCA J1PkqmuaOgdqlCkbIuvrLsjASFpsWTfLy5gOfdD7XBmGRPr9Uxa2xt98ng== X-Google-Smtp-Source: AGHT+IFt0keplQq8fKyimjQ51VejtKdYHtoj2QgxBTmKVKeBpzRIYOLhGWMqnQFsiAseuOBkeq5iww== X-Received: by 2002:a05:6a00:188b:b0:706:5daf:efa5 with SMTP id d2e1a72fcca58-70b6c8b4bdemr5295821b3a.9.1720785792704; Fri, 12 Jul 2024 05:03:12 -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 v2 04/19] target/ppc: Move SPR indirect registers into PnvCore Date: Fri, 12 Jul 2024 22:02:31 +1000 Message-ID: <20240712120247.477133-5-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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: 1720785842053116600 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 Sun Nov 24 18:23:39 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=1720785856; cv=none; d=zohomail.com; s=zohoarc; b=Puqi2tq2J9xmzOlYubCC6LoHlxEsbkrruvqM4sMP06hM5QZpJC36iSUo2qXhoS5aAA45c76dH02Mi73JZcKu5C1KCMKLA5RtCs2M7M5biqlzLWw8iekKwTIWRdPgeTJQhryk0/vAN0of+GsU2BE8GHSbqtjpU95yyC43FK3Vet4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785856; 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=l/mvcFdpzi+mEneB9Se+SZE1HP8IsEwqpEQveKRUpXJf5rTaJ0JEba5yOGQk5NLiAgIePeC14MtCFGaCqwY2gOKZ0fyD7F5I5v26eI5I/gx5X+m+oCfgOoDJeIL/WSyVuvU6JKBykgflucW8IRwWwp4fbYym3+ew+OUrugPQIt8= 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 1720785856597454.25960939302286; Fri, 12 Jul 2024 05:04:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0G-0006V5-47; Fri, 12 Jul 2024 08:03:56 -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 1sSEzh-0004gQ-7L; Fri, 12 Jul 2024 08:03:29 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSEzf-0005Zr-9d; Fri, 12 Jul 2024 08:03:20 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-70b703eda27so334304b3a.3; Fri, 12 Jul 2024 05:03:18 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785797; x=1721390597; 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=nNiBz7sQZ09eO3Y8RWn/e7qOJ+j8bFXxRq4JDw3as1hz4Qc7j+CeII9otVz9izknpv A1cG1E/uvSG13xGRxx15ieXUv3HhG/nvM7SWIGw8ROLf/vdRrNX9UHpwm6n71AZdtkOY B3RRONP9za3aVVxluHSm95wMFxWhnwjSf+0oEqKW+q/tjpiK05yCCKWQd4wR9kQooZ4A dVoviluDaGPy5C50YrQ25vYn+OljtGP3nIzt7sqJVSjVi21JKErVi3rnZLl5bdZkfNHU un5fXzzhAADNAIcUDqUAx/UyI+X94VFJjO6dP1jcy0H+HWPx9cR1Ajz+erv10hk3K6fp BCig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785797; x=1721390597; 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=KOaYSTPNdWmNHRwtf5BecPjOCw9975mG45P+5JT9c/SCOU3F3PngheFL/GXwlQJU8j L8iHasypXCpKQZseCahVxB/dfMFCJbM3mYFpHNKfwC4qfOG3XX2F9XAXruqizyi3kogH uLvYZ+XlVCa+X18xvLlQ/ctRpXqO8M7r0mK8rqg7Bcqs8UvfoDOtECUXcA+t13NrVniP eWzLQtV/nQou/d4Pt57wBXyDULii8d4gUACvDnh+fp2YTM5gumo94AtxeuHUWAyqdD8X iv68pi+rtdV55OBzbmZwBiK04WFlKQkHOCg/tBfZDPgfwJFLzgs1oZC4LX1Ssa3WSc+H rc3A== X-Forwarded-Encrypted: i=1; AJvYcCUtydlhrlwaff4zST2e2XCZx/gNaAcxmpJWjjAQPcfJo+jOthYGacr7Ot2zFBwNRccH+q+JqElcIhCRPW12fxbDJmGgUuA= X-Gm-Message-State: AOJu0YzFlPGoiPQj8W9QKOeCMjNxgBow/8+RHQvuvS259pvfIx1qiFR6 voDsqQpF5U38qduFb18LeFUYeVmckFlqePDqy5HVojkd4mnBbgS0UxnTCQ== X-Google-Smtp-Source: AGHT+IGZrPUFOKKc6wttAOrLtWfTaPuLwbqZC+9f+1OSLdaIdSe8kWLK9GYge6NeVJXJboS957na8Q== X-Received: by 2002:a05:6a21:6d9e:b0:1c0:e629:3926 with SMTP id adf61e73a8af0-1c298221bf3mr13184752637.16.1720785796762; Fri, 12 Jul 2024 05:03:16 -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 v2 05/19] ppc/pnv: use class attribute to limit SMT threads for different machines Date: Fri, 12 Jul 2024 22:02:32 +1000 Message-ID: <20240712120247.477133-6-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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::435; envelope-from=npiggin@gmail.com; helo=mail-pf1-x435.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: 1720785858150116600 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 Sun Nov 24 18:23:40 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=1720785875; cv=none; d=zohomail.com; s=zohoarc; b=dU4kl7PCKfy9OufyZb7loZwK0nYD6dgMEWEMRoS7CZdQfLNN2t8/9+37G5To2VD760GEu3psODGCpe6Nfg0q7xq0l8BV1aZ0da0+nbCejifameQAdocncGSgH2LX4Nc3IeFdNmFR5O63fgv0JhUGql/yETHs+dYmmoLp+FjvdDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785875; 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=k2CufG76JiVrhWgk6gUkII3bWTlt9Flv/3l+RpsyKeN/Yt26INxdcu9q1uWfn8VSm7ntb07YaWSxc0dy8QR39/VB0eBhv6fy8rp0fKogTOwZ85NrNr7vBPeJ9sLcPGPPnFD7RWk/obqmPadU7hEscItxjj+svShPy57oen+AXR4= 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 1720785875419160.85274081797297; Fri, 12 Jul 2024 05:04:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0K-0006mJ-B6; Fri, 12 Jul 2024 08:04:00 -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 1sSF0I-0006eC-54; Fri, 12 Jul 2024 08:03:58 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSF0D-0005kG-3F; Fri, 12 Jul 2024 08:03:56 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-70b03ffbb3aso1587995b3a.0; Fri, 12 Jul 2024 05:03:52 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785831; x=1721390631; 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=J//StK1JTREyk9a4flxY3ohf9nCE5mBQSdTXrr3/9fbEHgqJ5r2SnBhUa7oVlrm3qH UsCStu6+BXWWsLOd+nv9FTjl6B92e3GExX2CDgMHobHwkVPim/YY80LsOLfZ32YgOUkR lquQq/JjN3rnZdlnoswdQ5o0DAy1VII/P65F436JVE5RLd3nsshCif91XGY2CVzMjLJw i5EH9ZVjhpnvDQVDxI39HSQd2djdyyJKVKzb0ognWDs53RxILuHTTX2xgDuv6RxoeKkv M10h5srYnd9vaP0mjkaXzyW16IXfIQb141t8pv8Nk3l3/6Wzu9Tu1D8Cv1PLs5QqpU3B aF7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785831; x=1721390631; 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=inBrxG7t8Yn+xe95SP8t6WOINLClqFjBYFemVGA+/zKJA6F/rlh3S+NoEXKTCnUNwd BycBWVGBeoKtWmkkdKoZd3dVslUyjVBBrrXDis2tiLmUdCVJyaQwLui9/ATSid8wz/rx uQooU94bz2Y/OkgX3plDCFtNY2BgxwsrntmoRDQ0BOPMD7Cu5GlB+UjD/wPcW6lWoooq ewfkm2qPHh5RE4Om7C11CK8UuuYqz7fyKZPrbyim3eOYE2PNQIU7dAuEJknE6Poe3JMS D0o9c4Pa9UIXUIzhPbCHrV/8SSW3RQMPph8aeZ4zqMG/qQS0A4caoJeIRwTY+md55ShV gVqA== X-Forwarded-Encrypted: i=1; AJvYcCVs4AKII1CIDelUDm8yMC+yic1oIv1MiUzb6rdmRfaDwuBKQPcLYjgY5K8BJ6nh6ZWwpMcVyV9IjPEXIfPcjMCwC6DIFcQ= X-Gm-Message-State: AOJu0YyAO/dW/oV0mTElO9YQLYu7lSPwG3jZxoXzvarOUrxh+GmkLVpP 7zZ24OaF8LX8nj48Va1VCCligSRsDouY2C2viEhT6alh2fR/WkxqVI7qkg== X-Google-Smtp-Source: AGHT+IGu9x2z2KWdH5mv1DOLSgeaKSGBHm+5t0BW5W3zXg8vTFfdZTC1JUFAVAsGZUEeZqzj7Y1MQw== X-Received: by 2002:a05:6a00:1810:b0:706:7276:6287 with SMTP id d2e1a72fcca58-70b434f34c8mr14891028b3a.1.1720785800682; Fri, 12 Jul 2024 05:03: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, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 06/19] ppc/pnv: Extend chip_pir class method to TIR as well Date: Fri, 12 Jul 2024 22:02:33 +1000 Message-ID: <20240712120247.477133-7-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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::435; envelope-from=npiggin@gmail.com; helo=mail-pf1-x435.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: 1720785876212116600 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 Sun Nov 24 18:23:40 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=1720785907; cv=none; d=zohomail.com; s=zohoarc; b=Ce3OSTMhxYZAPZ1UHrPbt/2xXEEPgBT4qktE1t+y1jcPhWySjYEkxQgDTdcgVC4cy/EVijtes2sBGmDNQOomCSFjlFDvIMWxc7sQ9Bd87Q8IvtxTjBZplbhzztS6bEMkIG4FPp6Ak8VzxwPArNaqpowllXEzFtGqYrDo3dEZulQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785907; 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=gUlBOiDBKs3DeHpUTK/oTk9xzB7YqqaVjwd7x4gV8A1X+5Grxx7hlH3wxTJoOP9g1v1mxXtktZtc1ySQSWWmVBPkIRDI6gZVnHbuy+Y9ceygeoIWIH4aVQpMR3VSQm2osjL7pxZTXUZ3ZjLXTZR0fmAHievYBDGgmt9e/oFB76k= 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 1720785907809482.7301922641459; Fri, 12 Jul 2024 05:05:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0a-0007lg-2w; Fri, 12 Jul 2024 08:04:16 -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 1sSF0P-0007Ek-8j; Fri, 12 Jul 2024 08:04:05 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSF0I-0005lC-VX; Fri, 12 Jul 2024 08:04:04 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-706524adf91so1638025b3a.2; Fri, 12 Jul 2024 05:03:56 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785834; x=1721390634; 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=A4P72KGkuf/O7SggZeWWCzf7wQT3KtjZJ7sc027E+kz39zbjCmdBsakTok6eY9LMmj e0IaB5rBGq6gNWDRrhdzVukwO0AlHmNJgl+4RDgLftZlH+RkCXL8YLURtIJ881RXVmxk OBLd8lVcBiFY6+K+VQJuMDdkEHlEqpj20E57LOAKTDEdAMTeMmBGTRuheT+HPfsS1A8N Wf1eYKmRcUFayIVWILrndzpnuF8oHhQv+cz8XjfEsPdhiWrPV8T/Af+7ZF2I2zKLq2Dj Vh0t1IxENuSElsUroisvLRQQEToA/Qq39q+8yQLw8k0Tga5IVEo10W7vc8psrKEThlMu EYBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785834; x=1721390634; 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=nN+sXaPa4smd6C2qKxFrHzHr5/Cuh84kZ9Sd1eLcQCh1cihL+vfPYOcdlDEfNMv4UB Hm3DRvWKGOeNRE1EWnBl+tKbrZzIGULj/QEUySTt9hH/xXbhp5ser1cuO/DResdcoF9C nO7aYyPyVV1GWVqMTyBzZd6Nf1YqwoMXqy1UFhAa/21vGXHs9TEA9NA5ytawfmc0Cz3d ZX6pgsjEvAyfVikj+22hoNwDb1DZ4asJ1wxJBVgsppwLopDMeX0fT5wWP3WbZE2Wyu21 NvFmJK+D8zlWDsjdc9JPg53fQxoz9xDSH5T4ZHPIwqrQxI+KgUO7yUmY0Ydm3nzYKKT4 uxDQ== X-Forwarded-Encrypted: i=1; AJvYcCU43tl+6xDI2ERPndOGLEHODg1+pz8SAKs5EF+gv5H8sEGGvimowRmQCz7JdqHdtTkAog/BrPFd1zmc8vFaNnmuA9QStYQ= X-Gm-Message-State: AOJu0Yy89wu1S28wcFUOYQ4dIYvzYdcbZIOexyewMFGaIVHnW7WxUv/C 1g9Z4V2TKc7i0yFr2VePLYQ2N9lk7OeeyfgEM3q8kfL1jtV/x39N3RJogA== X-Google-Smtp-Source: AGHT+IGUb3+4YNWxw8JvuNUFHAX23Ml9NK3YwZYylQ9KoDvfRJ8OinGvAtGKWafxS8lJkG8PBmYrDQ== X-Received: by 2002:a05:6a21:3393:b0:1be:c2af:5626 with SMTP id adf61e73a8af0-1c298209096mr13417390637.4.1720785834472; Fri, 12 Jul 2024 05:03:54 -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 v2 07/19] ppc: Add a core_index to CPUPPCState for SMT vCPUs Date: Fri, 12 Jul 2024 22:02:34 +1000 Message-ID: <20240712120247.477133-8-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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::430; envelope-from=npiggin@gmail.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1720785908362116600 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 Sun Nov 24 18:23:40 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=1720786082; cv=none; d=zohomail.com; s=zohoarc; b=AxhbmpeF4bIl2267RH1lDPVj2XyqAfuLL1vKkPgLohit45jaxUNmdKOD7BRtONpZ3UAxX9A7HsCpOEOM3RkmNuGYM8uYowAdZ0o2VSnQRr9LlxowN2A1EbVsVV32ghSPgWSgiXCasph54+Kr3Q/UrO38xtP1Oif1WDGFACeo5W4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720786082; 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=JBga2I+RJLzLzc68YbUs//oxweh+N7qlLExQJvrEv7CsYg7UNsztLYGRyLJgTkOtSIp513klqJqhL2G2gbIB6nFKKHwAcf4kcetMGeN+e7Vq83AK6kcSOAxWol0qFK7EMunaQHFcv90Yl5FMNJjGDiFgOBM6c26k+pnfx+bieg4= 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 1720786082054477.48025962224335; Fri, 12 Jul 2024 05:08:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0c-0008Lc-Pe; Fri, 12 Jul 2024 08:04: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 1sSF0P-0007G4-DH; Fri, 12 Jul 2024 08:04:05 -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 1sSF0L-0005lc-Bb; Fri, 12 Jul 2024 08:04:05 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-70b1207bc22so1630405b3a.3; Fri, 12 Jul 2024 05:04:00 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785838; x=1721390638; 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=QDgylEeoL96pMEdGZhTgbakEOZCnO2Cryj/Aeo9CeYDkhjVDV6e52WpYxJGV0XBLky N78n0xCC6W0TEDl9JFQZEEY7Pp0eP2foaurVKSNcuPUrVco0TfgBhvVQOFNTKNqIXzGg K6VvGn3ACKi7CcpXgxxIdW+2QLG1is+1XpOZPXfaXITkMgNGmXNng+IpSKHUGNan3poS eQofK7jwTdjxVtzLFivqwyErPWzPyBj3vaOt6nwSTmDQ6alWAV/VMza6n46ZH7e3g0dn cK9+/OOR8fnt74zEATo6aB5o6MrqAjLoCUT0fsnQTnkLZrItNRnWv2Y0mDln2xaPDCxn 70fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785838; x=1721390638; 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=ZaC0xJWyrKlWuCACxouf/jV6bQ1l6GmBZnxrKRgEDDbkbJdHU9knZz8iS97XojwJBO Q5ben7uqToS4a12Cm7sTM/kEAfhIhfXASm/6QZjxnijKak/VlUWfYhoWhe7sXJPw8sm7 M7QAG6shzA3Fi/A6FggIE+RqT3n06L33Oo+VU5iBII1hWi2MXmuNl3BEocB8beRtrDmT BOEjLwGKu+E/11dffi5YKRiTEkB6hErbpwEAa28xGMI55L6VpZuQgZ17Vnso4vtAlVF6 25I7714dvArkveHJpf0M52/REP0MyxozQG28AenlgO6w5vIz8YPTIDph+Fhg0IpVaUhK c2jA== X-Forwarded-Encrypted: i=1; AJvYcCUK3I/QxuX71aH2FshVFwjzEUojLTyS7wwkLvfo8RuxQ+h8zYNVHLffqrBlthATCeZ5Fsa1VVbBWAuljMphiYnCnFZgNts= X-Gm-Message-State: AOJu0YzwErl3uyEnmOd4EC6PvvrPGbX7ReOmp3vSj2v0iNpjQ9wH06AJ tEFUEd9QncKOeGQqA9CkUI1W9rkhzG0pJKgW9/4Uu5z3pH1donvwqcu9QA== X-Google-Smtp-Source: AGHT+IGQjSu3XRfk4XkJff6pUJcl1gtHELi53tVS1flhrOij5QtviBjuI9zKdiRglOje2IrxTIU9qw== X-Received: by 2002:a05:6a20:748d:b0:1c0:f267:11ad with SMTP id adf61e73a8af0-1c29821d031mr15918382637.19.1720785838056; Fri, 12 Jul 2024 05:03:58 -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 v2 08/19] target/ppc: Add helpers to check for SMT sibling threads Date: Fri, 12 Jul 2024 22:02:35 +1000 Message-ID: <20240712120247.477133-9-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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: 1720786083398116600 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 Sun Nov 24 18:23:40 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=1720786082; cv=none; d=zohomail.com; s=zohoarc; b=budboWl6aSFU+ne/mVhpB0SFGNrpjuxRdZUxQ7a+6OcjLe4OV2NakQ/bznSfoaiWkL3hdnGeQqiEX2jrIgFs9yBkBQc1B05zfrgVigT6oTnfIHX2yiJU6C3h9HqYjW5ITkdIrKXzDo/hoR5UGdI1r4DEPEr0bl4eNINxoW4wNy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720786082; 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=gClNrGr+yRZe2ooBv8T0cxSyHe87imhCM5CEqqMpBYuMN9bzcKKNbIwdDJh7Sehw2KXmSVCBSZO/+3q7fiN5nDMHV0KPiZDyqJPjIKVi3QPtoZpTOUQSgVFuRjyjOAF4kRpJ8nOmfqn9rkH0KBt0OJOFLaMS500kvfLOQcUH26c= 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 1720786082044554.370191335582; Fri, 12 Jul 2024 05:08:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0c-0008Cr-Nd; Fri, 12 Jul 2024 08:04: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 1sSF0T-0007Z1-T5; Fri, 12 Jul 2024 08:04:10 -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 1sSF0P-0005mA-BY; Fri, 12 Jul 2024 08:04:08 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-70b2a0542c2so1832943b3a.3; Fri, 12 Jul 2024 05:04:04 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785842; x=1721390642; 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=msi+3ijayEx3gUCKsqc5UGcaKzRxy1ML/8ZcylUPjg0N02TVXfJySjw/au9TjagDkG /MlwVM5JEWcjmVg6jTmz6rc+yUA06yHfQM+bmwhen2s+dOkorvvb+VbzArhErrkRX2vC l51AEniNPTu7KW9pEPAW7G78pMvb3T7p87RneWcySxKwbA/ZWAZf9h2TeQUxJ1GP3Ywh np9ukT9sjX9ExXUedmhguN8YmgE/fk/lEr0h2rq4q1neEC+86yHRitAPp4V4jErGS5Ne PId+5SvF9KGLGZ0LBabeinjRIUWw9OXmAWnZC5kH+0bzkrj84fNU02eUH7vMIIUzXv5v nVvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785842; x=1721390642; 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=uD8kVHKjiDaiOQhCq/vU9L0dMq5CqZO7aOL4190/MpMM6NcwoM8z3KmWPjubTlfJqX XFiSLQB77Hnf4ZnuoXRhK1moUaJAJOE82PsuzQhYGsc3I5dpCUlfKegx4mDTONopIM6V elTuoz2ie5QXjYkdLNjmsvRwidS2zYGe12kVnxifh6Oww+K0okIOHmjoL9vAoVO08YZv r4Pk4FTGUAsHJSgc38uiXABwelz7Bw1Be8RepcQE+miT1dH9iyNAhb99LtCnLjWEWmLf mblk5FZucSrBvDcSMW7b6/u9kOgZHDbU+t9xCtTpx2AgFUpHtwy4edCH15IHRqmLlnPm FPHg== X-Forwarded-Encrypted: i=1; AJvYcCW8UnlxUBv1UtMMGbfS/ivdo8jKFkxUiKvwtvKnoHD9hyP5Aq/neQ+wk83C8z80OHWW23gW5OvG6d4mZucZNAmAW7q1Wlw= X-Gm-Message-State: AOJu0Yy/vQJIJiyXqi8xlznsh0r3D0dZe71Mf/bp3Fe4xuq2JZFzpBGi zMy4+Gcvjw8UKKijUrXwNOXhLlPCDMXAWH/FO0UlrcibZLlKRQpQh1jKPw== X-Google-Smtp-Source: AGHT+IExA4Vel9ApnDgpubmx+RLGFmxlFbp+chx5PXO+EfaNSBSDMBa1OQQd95Y+UeR1CdJk1AdtVQ== X-Received: by 2002:a05:6a20:9145:b0:1c0:f594:198c with SMTP id adf61e73a8af0-1c29820c067mr15409355637.11.1720785841739; Fri, 12 Jul 2024 05:04:01 -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 v2 09/19] ppc: Add has_smt_siblings property to CPUPPCState Date: Fri, 12 Jul 2024 22:02:36 +1000 Message-ID: <20240712120247.477133-10-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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: 1720786083366116600 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 Sun Nov 24 18:23:40 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=1720786082; cv=none; d=zohomail.com; s=zohoarc; b=CWOWGML5FMTYufDPn9o8bU4Fcl/BA2Dmm+N2MnNOuyEGzobuJibj2Z3kcHDs1jxqiAhszExKkX1GegrXUpnjIWq5+o4y0/jmlaANHBgcsUPSnsC3T1n5Jw9sGmbxmEZKc01bYJV6/UQ563AZEWNYnQtGk+kAQGEoiljD+oowqlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720786082; 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=6M/tQo2Opo10sc9Z8mOoYDPsrcz1Z2W05xJovmSQA5g=; b=ILxUxCvm5V6r77RhWAiv56ArD15k1ZJL+0eCjqzbHLaw/XZUPaDtFYPsTzxxSrncHqcHCyJEG91vGO798XfbdjN6ZJd66APIui0BSNHPo6SdVXMCgwyRtXD63LWV5Plbxq4iUivz+IzSFwEehjMJUS6Nye0jR3reF/pLJyW4L6M= 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 1720786082096210.7946842779976; Fri, 12 Jul 2024 05:08:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0i-0000Wa-6d; Fri, 12 Jul 2024 08:04: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 1sSF0W-0007mg-Mv; Fri, 12 Jul 2024 08:04:15 -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 1sSF0U-0005ml-0s; Fri, 12 Jul 2024 08:04:12 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-70af8062039so1548912b3a.0; Fri, 12 Jul 2024 05:04:08 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785846; x=1721390646; 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=6M/tQo2Opo10sc9Z8mOoYDPsrcz1Z2W05xJovmSQA5g=; b=OASP/BJTHLdUQ0EpsmITfPQBW1FVShi8EuvnfO35o6HDNLFDUEEEeIDc8/D2KyMHa6 e5mGw9cXDHy++D1sKQZstV0Mqc/MXOU/3+naGwMvnU+pgIlZlwPSWkood+G7O5zlayil +fkmbzBr3CVucDBM533FBY3FtkikiU3/TvTSrz3AtcA+SPLA2sDUr4oWLR0ulJkSfwf2 JbFJXkujMKHgIEnchaZUCUd9YE8pHNnIHvBGcfCl3F77fU2eJ/zgS0joBmRNW/AqBcr0 ovGourUE8ekCFZLZ0h0Yqw8Mqo6Hr4Y9bgjZ7tTW6nj0pU8l9oammQsdj0eJckgfZ1Gs ZAlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785846; x=1721390646; 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=6M/tQo2Opo10sc9Z8mOoYDPsrcz1Z2W05xJovmSQA5g=; b=afpbSIsiBB6j+whsathXvnhpfZsd731OaM2gx5BlY4DBXPCUBqhzwmdIFJLXaIbtXz 04sKz3f3rHat23RKGAMZx/B3BwcX27QoQ1gCrjPeHGX2Ge/6N01s8R8b989bXw6i4l61 ofSnk3A9uOwvfHFi4rM/uC2QQJ1jStqhpRNxD5UQni66FPfIb/oiJI2Eje8hGpGaM98b UQBvbjOYdmlqoyt3QHn/yS5k3Cv3bevrzpOg3AqUHRdKJNBCjYvbHlsEpZsaxrbAatrO QAzdj3fKa7JZifcjN8nKDsljEuaZxLnk7iTDHrfQOpUXvfZJBSBNfyh4txCtd+GiRi1L 5RXA== X-Forwarded-Encrypted: i=1; AJvYcCXVNMjGR2cYz9JeplAZIJI7cErP3vRFqVegh6HA+sqfHJUuwciDx3JDdNm1qsVKEY6jBubJbQYRnZOjlC6lmo6yTFeEOyY= X-Gm-Message-State: AOJu0YxRwAzDkYINVvjCUVfukgbSRMBGwJ6xvWhoRn9ktxaEPTMszpd/ gkJLGCRXvTRdnsxWUgoCWW+P2h0SycvdK62BZItnSB6nsWfHYFlb++n2rw== X-Google-Smtp-Source: AGHT+IHmnDQ2xaI1pfDZ2oIuUk+m90dys7AYSeMHGO9Zu4U+8zO5DF2Uid7VBvLEjaCisrfscrqVzg== X-Received: by 2002:a05:6a20:8402:b0:1c0:f529:bad6 with SMTP id adf61e73a8af0-1c2984af997mr13330740637.45.1720785845662; Fri, 12 Jul 2024 05:04:05 -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 v2 10/19] ppc/pnv: Add a big-core mode that joins two regular cores Date: Fri, 12 Jul 2024 22:02:37 +1000 Message-ID: <20240712120247.477133-11-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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: 1720786083371116600 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 | 77 ++++++++++++++++++++++++++++++++------- hw/ppc/pnv_core.c | 7 +++- 5 files changed, 74 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..555a983536 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); @@ -1175,11 +1200,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 +1234,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 +2217,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 +2239,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,12 +2273,14 @@ static void pnv_chip_core_realize(PnvChip *chip, Er= ror **errp) } =20 /* Cores */ - pnv_chip_core_sanitize(chip, &error); + pnv_chip_core_sanitize(pnv, chip, &error); if (error) { error_propagate(errp, error); return; } =20 + chip->big_core =3D pnv->big_core; + chip->cores =3D g_new0(PnvCore *, chip->nr_cores); =20 for (i =3D 0, core_hwid =3D 0; (core_hwid < sizeof(chip->cores_mask) *= 8) diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 8cfa94fbfa..16d40392db 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); --=20 2.45.1 From nobody Sun Nov 24 18:23:40 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=1720786071; cv=none; d=zohomail.com; s=zohoarc; b=GYkkQ7vVQjJ0fh8LRO2kf6fcSqADOegczZi8W6FbrAo6M3Tl3p5pm+ffg1zDFW7HnjMDYZc4cH57QPKauwkMrCnTEGvQ78EQc1tDsJ8Pb6wqDH6wsdjjggFdS4kXx8ZFKgijkBYc4d0eL5kYCR1t0YdUQGiW3eiD0hmboo+F3/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720786071; 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=SjHzbLt8jHoeH3N+MwM+HnAEB76eFaxTqHRzPHz1NO8=; b=DRKxPtshuKeswxP1+nDCQGM0yRMDM4tRe1Ry9ai11V7m+W2ZfAPB9xofUZK1+T10ywnEwC/QWZCzTXjlnuuoCKbVyfKjgTSBb1Ub/WH6On2oTXKylEea36Zct2/69g1ILH2sveogXrYomHXVmwQ16rzbsVJWlugdq2/CDvClq1Q= 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 172078607135165.08917572422956; Fri, 12 Jul 2024 05:07:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0i-0000Y9-9t; Fri, 12 Jul 2024 08:04: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 1sSF0a-00085M-T3; Fri, 12 Jul 2024 08:04:17 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSF0W-0005nF-Kt; Fri, 12 Jul 2024 08:04:16 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-70b0ebd1ef9so1492684b3a.2; Fri, 12 Jul 2024 05:04:11 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785850; x=1721390650; 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=SjHzbLt8jHoeH3N+MwM+HnAEB76eFaxTqHRzPHz1NO8=; b=OpZlBS3TqTqxs+d7sKmq0JAFqHOsxiHcM0g7M2DEb/m7yjxXIi+e1bxfwOA6d13APK 6mQiabVwmSFcJdl5w4RDO4BBKNMR7fwH65AoYwrckMbLb0mMdju87E1obe86GU0CCPzn NyiRt2MQ16mk1ByEUp3UXEDXHtLaDWPcVHUtgZ9peotOjT2B0/5KLf3Orerskwt5Pa/e be2HzEFGepZMqUCj3CNwtm6beE9RprtlUcJOk0HT6Y/kxM6XCfR/i0vHXwGQw9JNKVCG SxmTbWhL0I5xzLzyOke2+2lDRVH8tauo3fTtmlOj5XXfi5pxMJA1zUg3jK+aG3ccX1BD NIcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785850; x=1721390650; 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=SjHzbLt8jHoeH3N+MwM+HnAEB76eFaxTqHRzPHz1NO8=; b=JB5sIueO4lFUYLqboJ4GQqpfaxpPF4fq8QTfq1n5hx44QuSVQYVL0twS6CeAjjQetP qDcDaGYg6EN/zdME9HfZ775mn6olgbARVQu2Y3vEtCo0zxaKMITY6bdBjSQCJAzCg/8n XLcBx4VT0V1rI/g2n3yq3him8/TFAzNTpkAyZtExJphqiGK1Qfcih6EOM8rhVPcxysLU g7v5xl0dEfm6xtDlp8GeyemYOLAFSKcpzETxICOOlwUNU9h79JDfa9jELf0sDWs4y8Am 3QAKfA845+lT+ujlxXD/yWsnZiotLUaHGeX0RLTVBOP+TG2127ymIO39cfpIgzi/Wrcs nxQg== X-Forwarded-Encrypted: i=1; AJvYcCVz+4nGvIMu44emu7x015MYxu0DTLX93Rlb+Bxv/KXT4n/g6BB6I770OigPR+TOtZ+ODvZd0bmotENWSTI5VbruseyGVNA= X-Gm-Message-State: AOJu0YwZok8lo8FzaWt7NEGN+921Szkl2VcHoGE3oO3eVIE+tKhOD8ti MXN9c1hvYP7vZ1Q4OUrq9t49To8oQKJLvzcZy8TkSQ+3p4VNYrzgEvjfXQ== X-Google-Smtp-Source: AGHT+IGFwoNCbZqWaPSonUMwf0Z/Vn7mJfbc5VAjopuBH3wEtoZBVBbg3UCataG7O6UZUtwFTpBAyQ== X-Received: by 2002:a05:6a00:1955:b0:70a:f5c5:135d with SMTP id d2e1a72fcca58-70b43667750mr12801681b3a.32.1720785849619; Fri, 12 Jul 2024 05:04:09 -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 v2 11/19] ppc/pnv: Add allow for big-core differences in DT generation Date: Fri, 12 Jul 2024 22:02:38 +1000 Message-ID: <20240712120247.477133-12-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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::42a; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42a.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: 1720786073271116600 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 --- 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 555a983536..fdf66323b8 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 Sun Nov 24 18:23:40 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=1720785889; cv=none; d=zohomail.com; s=zohoarc; b=DzK1+B9mqBbOGNykYnJh6fOi2NAhE8hC8LbO3oMhz3o2M7MvewgZRMvBwfnY6iKu0sUfUXkw3UXDwUrZgjyeWJd5wBOSj2Wye4vNnGiZ8zim2BV9frGOVv5PK/xTMT54pjfR42rBZAPl21DKBAQRTavQOjfxWZmwsHfw261f4u4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785889; 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=yCH6qpWycZzToOnNXgL5CZvi+FOCKYD18A0yufhOzBQ=; b=iOwuU711yoiUsvniXjgvtAnTh2g/h3wsKMSAMwBgjgjDTrQGUmA/eqls4vLvwS4QBSRWXar7F1Dq/cPQnYO4m6JfzKQrs0jC6Wczb7j1+noej/1bDH4Wro1GSrNaolwrD7K2I+CUdKO15l0DzO8b3CaXs+wIGwww62JRytbqwi0= 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 1720785889574760.0737804499937; Fri, 12 Jul 2024 05:04:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0k-0000r1-VD; Fri, 12 Jul 2024 08:04:27 -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 1sSF0h-0000Vi-U1; Fri, 12 Jul 2024 08:04:23 -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 1sSF0g-0005o2-0y; Fri, 12 Jul 2024 08:04:23 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-70af4868d3dso1691254b3a.3; Fri, 12 Jul 2024 05:04:20 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785858; x=1721390658; 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=yCH6qpWycZzToOnNXgL5CZvi+FOCKYD18A0yufhOzBQ=; b=Ygy1EyCRF4ugpM4/CF/t8sYNpe4ZgmazYs8qs/7raqwMkXL5nh24R6QNjQudmNHMlv lsni9cHf4g1KahN+JwZNMfOki+9PUATIFZF2RGioFBfC8V9j0831I9JgVNNYfbXsPXnJ XdnNv3xvxJnlvRIsDjEgCGDuUyr0+c4p/+OKCwhldq4CoZSQhv7iBEHfrslgMG926xoJ kTcqNnWJJFPpVVKmp6OPWIsxbc1HtUV3RubpGgDexjESftmfO1uy3pGMiMLwSwiIWIOD 5KiRrS0JiRehqsqlm6UXROUdLD3z6hDri3XZvT+hxUVFUENqMsZoGk0fA+asS+vyUbLy JhNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785858; x=1721390658; 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=yCH6qpWycZzToOnNXgL5CZvi+FOCKYD18A0yufhOzBQ=; b=d69HsS1Z6sEv6YU4p9NyOd5eHUWT6Y/T+/IG0RI9wBEp58/pkIhyxBBz4f1JBNi3it PD59WdUYvCMw/xGuSp/bR0EM75P7PJZkau5atPHRB4wMbu2tslq2xjAZPqIOJSVgG2K6 ucOkt1xn4WzBRwUlUsApsOQqzVNdSI8VjFvdDATfT125KdFCoyZMdxskkzZ+eqRK2DT7 4HGUYT2ALWMFPWX02s0YvcKYGfgLLo2xwlhPsmrhz0EK6RNlYQPSiRF/5vbfXbPZYIHj H1DVJ5xWvWvHMa9/MdHLYJxdQcblk8O98IwWHuS60PJb4tBaJSLzL6/BW6XIvZrwo1dU HvFQ== X-Forwarded-Encrypted: i=1; AJvYcCUovjKxmYDuPMbgLqn4Lf6ksUl+5cpYzh4WgarcEv5B6p9czQ50WFbubAgmRHZ9c0gp7dopBArQBVXCkxSDmr9FNpyIgB0= X-Gm-Message-State: AOJu0YyiuyW7HsM5qg0hktq03hleZtSYWzBqT2TNpV3qqLK4wSlvanfF /T1GvNd0ZN2mdSQ9VNW/fQpR07ofdnqv4Kxy/iBvxCOuPVYxw9v9pqklZg== X-Google-Smtp-Source: AGHT+IFfPvJ8NKj+eaOTKUPH8DlkRFNBl5VDdxjMFX6R9xkWAc8UfDTlsTmkTACIEVUWv7AKaBMJJQ== X-Received: by 2002:a05:6a20:43a9:b0:1c0:f07d:159e with SMTP id adf61e73a8af0-1c29822dd8dmr11848557637.26.1720785853117; Fri, 12 Jul 2024 05:04:13 -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 v2 12/19] ppc/pnv: Implement big-core PVR for Power9/10 Date: Fri, 12 Jul 2024 22:02:39 +1000 Message-ID: <20240712120247.477133-13-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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, 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: 1720785890304116600 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- 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 16d40392db..a96ec4e2b9 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 Sun Nov 24 18:23:40 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=1720785910; cv=none; d=zohomail.com; s=zohoarc; b=WptyHORQm06EOvRlG5XCIC+HDL8W2td8gkhUQF4zWJvAdkDVUNFvwjQQbUipe4gEwKijgRxhtcFKmvnRpiU9z+kvtUYz+sUlZT67iPTh9RzFHNwf3vKJD3JhQQHn5w3fddpzcWIVVxKpxFR2i0nv5MsHlEC+5PrSGhUgMcsAyig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785910; 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=BMtIVzlrfw6fu08TIh+Uxc1Dl6itZPW/L7Wa3SLi/XTR+6ievkPyH4wUiTT15bRqvUHDoHmNjZa4wpCW3XvsmpCzrsOexxYZAQkI7CWOz+u64qxsayFF5xEoGh65ShPXEXc23pou9rOTSfm5v9ptEmoLVrEk+rYrCILdesEJn+k= 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 1720785910270666.3027720458068; Fri, 12 Jul 2024 05:05:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0n-00011u-5s; Fri, 12 Jul 2024 08:04: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 1sSF0k-0000o1-Jo; Fri, 12 Jul 2024 08:04:26 -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 1sSF0h-0005oO-TT; Fri, 12 Jul 2024 08:04:26 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-75c5bdab7faso1153190a12.1; Fri, 12 Jul 2024 05:04:23 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785862; x=1721390662; 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=BDAx4z2Yf36JqfhyQxQTjXjmmB0F8t/tzd3sQKWRKZYvtA5Xx+T1ZMIz2mTtMzXDZz buMU7UjM2jSCXX+HrjHvnIovGzay2BgbK1gWVsrYvMQxInbqlsz6Mr+4ZFRRhv2Ny4ns ANdnglIptw8hPsMdEagZdVkPraEla1mvolhAjfLBITkIWWYXjG0fwX79gyl+gmoZy72D F6Ps2BF8K3nUXziZd6pLTd74GbakXKd1HxLQT4oPRJWf8k6fJn6Ep9vGRV1nrWQ590qG TlwhFbL20JtA/1O/lJpA4tpZ+m8Oqf6pSihNbG8hPMWE7nH23YAQE8vpx+lRRIjjdL5N rVyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785862; x=1721390662; 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=YxJTrY4an2g1BbaS67E00sAyCt3jIrvt+pMY8t5I0CqWL3ag2ZC4dE2UWpeZj5dP1z ujZzrt42GLRrEbCgs8FjR6rpI+7OJkPD7DNaDZxueEpX7qpzIGkD4brRI7etzQb0ScXr MjV2H3IPMLI2kq9CgPvCShfh6gZ313ewHdEiRuw1Xf7g4WwxxTG01sjDLD0o5AcMNqtB nKmLv3zokpfzZ6A4m+E3jIY6RvDNzlCuzR6su9pBJIaAMobtBltMSr52HxJiroJJwBIE oCa9JFz9JVoUsASPNO8sO8PHSMl8vlvUrRSmRsya5ZJlmFPCXr/hn9US0Y5raeknM06y 35fw== X-Forwarded-Encrypted: i=1; AJvYcCXSDX1aApRIXSHF6ZbWhZbA56a0TIok40X/NA9lh1V0/TV4JFjt9Q7unLgjPqKQECstDCRUw+FnArOYiy2UHPWDQjGGCps= X-Gm-Message-State: AOJu0YyHwL6NLPWIIQm69Ap8c60C+ZP7lu60ly+cEDkdWqNBTU+ixPmu yOj2WmPo4uwxrO1G0DBNM7XC3isQVJbkoK1cE+aKL1UN/rNrTLhlyFg0cg== X-Google-Smtp-Source: AGHT+IH3rZqRp5M/Bb5J5vdgaHZDCtshUfFeNET2SCkD/JW+Ex4B1E7UG1cwRdoc34GFdvc7xuhnoQ== X-Received: by 2002:a05:6a20:8422:b0:1c2:a696:6a48 with SMTP id adf61e73a8af0-1c2a6966b9bmr10057010637.48.1720785861766; Fri, 12 Jul 2024 05:04:21 -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 v2 13/19] ppc/pnv: Implement Power9 CPU core thread state indirect register Date: Fri, 12 Jul 2024 22:02:40 +1000 Message-ID: <20240712120247.477133-14-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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::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: 1720785912415116600 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 --- 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 Sun Nov 24 18:23:40 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=1720786006; cv=none; d=zohomail.com; s=zohoarc; b=ZeVp6oeeCEvbi/eKtnr/W7ijojyUA30y+7tv+zUdZAaO/r3PxOqGqdNrj7SD/6+poVAshhyrbjkuMqtPDE+PPjgMOUeKC145Flom8oRpYhD7844r/K0lQjgChMdPC7CIPwjpTmH6KDLplLfYxwXbiBrBfyCTWEMBxD6/qBj3TxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720786006; 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=SnBixgNCZR5umEUBDPQD9xrONIImNH7KH0Dw6R9WoY0=; b=Ty2FGiOQ6VowNEziDtzfXx7qAb01h3hNtG08hwO0PmGYmailL2o/fpK6KztcKHB+ab971ne9zMGctJFLPVr4cGSarFAPsWb28Qvd4cmoRMdziB+CNQ2V3JROJ3+kf2an29nuOvaQbm0Pi5NxCKqtPMkGrAyvHSS19Ue4rKbEFVg= 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 1720786006281183.55017747973113; Fri, 12 Jul 2024 05:06:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF10-0002eE-2F; Fri, 12 Jul 2024 08:04:42 -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 1sSF0x-0002EU-BN; Fri, 12 Jul 2024 08:04:40 -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 1sSF0m-0005qL-JL; Fri, 12 Jul 2024 08:04:37 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-70b42250526so1515821b3a.1; Fri, 12 Jul 2024 05:04:26 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785865; x=1721390665; 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=SnBixgNCZR5umEUBDPQD9xrONIImNH7KH0Dw6R9WoY0=; b=gvZAOFj6gnA+Uq0fQUYniX/HFImQv3t5QRp2bzbMflp1WPwECkWZsF9BrjQ2ic288A /4d+Otpsn3XEtq9kWtR1PRCF2OW7BV8yd8OyYebZOerNgN0akFCwKxv6B/RLGoknjb+V YscLlc/28KkeRgvuodW0zuHRKeFAgHphP6lTmZDtL9fHJs4CBghuEfLyliZCNMrhLUvI CXq44X4GNJhQ6axUz7AOX5XeGfwd+ti3ScxFgv75WjCwJS5VhjoyBT1L5ohoKedRWVU5 v0i1ljo6VnPtJq4FVpCfz4wu0IS/2Ajhk4v1CeFUh3T+XyUdIn156hbJy2rRYeGziVBr thDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785865; x=1721390665; 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=SnBixgNCZR5umEUBDPQD9xrONIImNH7KH0Dw6R9WoY0=; b=PBRgDqHOaiOD5okImaKJqOawJ/513tgo9hX7UtAKnliBxYzb69H1zl+OdM45jq7K9J 5w1EsFNykoZjdSYN2EqB5QC6mElInQT5XRBaN5DwTX1SAL5H29z238+0btu8FuHrvB8o 3xSF4yxgDXvuiHaYoUmzoKEttEGJMMq1eEkadKzVqlo0Gq9HTP5xV51tdPM3aHJtm3RB PoHU7iIS7skQ7UwALmLS0tNcUbQlZSbBM3koVj0MISAiFqAjeVdko4F3PT5b8PjstvCb FHVRMzwZu4HXVY6C+AWT9Ghnjdhj8njICvlUjKpLPAb28sr9mC8wX3e5dxzcDSL9n82S Y3+w== X-Forwarded-Encrypted: i=1; AJvYcCVzzXlrRmjaqWb691Jw4jVNWAU+GCV6dvPJlJJnKJfYi34/HblAYrwgWFNJkZbGYW+vV2+mN8HcQKzR8+BhTGYBMEwC3o8= X-Gm-Message-State: AOJu0YyyLo8/HK4pfiGSUQMJp+8ugfxP6PO14vlJO06X9Q+hfsmLCanH FVg5Z+vOa8sPHjg6oZJj6p8HgLvfzHmmcEk7UlWLOeqZCqtr5i0S4uGy5w== X-Google-Smtp-Source: AGHT+IGS0tPCjl7Wg1M5TBfg7AKkIF/WLSCuxuBlRiwFP9hOAWkrZzs7T5rfgnnuPv8PPbavjksP4Q== X-Received: by 2002:a05:6a00:2e27:b0:706:6824:9c53 with SMTP id d2e1a72fcca58-70b435412b1mr13544838b3a.10.1720785865198; Fri, 12 Jul 2024 05:04: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 Subject: [PATCH v2 14/19] ppc/pnv: Add POWER10 ChipTOD quirk for big-core Date: Fri, 12 Jul 2024 22:02:41 +1000 Message-ID: <20240712120247.477133-15-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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: 1720786007028116600 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 --- include/hw/ppc/pnv.h | 1 + include/hw/ppc/pnv_core.h | 7 +++++++ hw/ppc/pnv.c | 7 ++++++- target/ppc/timebase_helper.c | 9 +++++++++ 4 files changed, 23 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 fdf66323b8..24f7c007ce 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2288,11 +2288,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,6 +2336,9 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) &error_fatal); object_property_set_link(OBJECT(pnv_core), "chip", OBJECT(chip), &error_abort); + + pnv_core->tod_state.big_core_quirk =3D pmc->quirk_tb_big_core; + qdev_realize(DEVICE(pnv_core), NULL, &error_fatal); =20 /* Each core has an XSCOM MMIO region */ @@ -2647,6 +2651,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/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 Sun Nov 24 18:23:40 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=1720785891; cv=none; d=zohomail.com; s=zohoarc; b=iqLqaFwephgpRUotXOxg0OtD1tFKVBceaqf+5uEOAf7XAJ5/qJcBUrSnHi03zasGgXdjdSjEmCbjGwTCOx0y93Eauw1i2+tPCYKzpEZ6iJKeQHZQ+ro7v6MlUhvLEMAcR2r7AkhZMqmJpZg7b7ylEHaP8wc8og9M8tEt6PPNHp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785891; 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=ILljuqyS396GZphJq1/X7QybV+ipPMbO/Gt67zfSb9g=; b=lyzBTqLITzKofizHQ6wF8Ddwjk2EDYpOvas/v7wrWA+nN6El8O+UV51swMayLeHWI7nEHs9gemlpD7pDhwYW8p2SUuM18DoGYdvYkZegGUc8S5NZ9BCZYQbkW6jEMyIVTN5CMkGCAts/M6hhCN1ZUSEwIkr57scNcqtZDE2ptXs= 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 1720785891938331.97312575587716; Fri, 12 Jul 2024 05:04:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0w-0002GP-Kl; Fri, 12 Jul 2024 08:04:38 -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 1sSF0s-0001rp-RI; Fri, 12 Jul 2024 08:04:35 -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 1sSF0q-0005qz-Ar; Fri, 12 Jul 2024 08:04:34 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-70b5117ae06so1438518b3a.2; Fri, 12 Jul 2024 05:04:30 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785869; x=1721390669; 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=ILljuqyS396GZphJq1/X7QybV+ipPMbO/Gt67zfSb9g=; b=YknrTA2yt1vk11J6oJaaFsja/rJCqJXfH+gXZ3cQYsdzHGY+gPPAH2MiLihkOQpGC0 G8mw6ViRkYpT0SEXK+CKjKhpP9ukwiE9ka1l1ziVCoG9yQXTABU9y5JHh6QhLDxnDUp6 doyF8FWM6ckfQRyxmLrTYj1TzIL1CVB2QPmwNefoKXVcLjiOJx4uUvsxqXHysuyaRfYx l50J70KZaFTlH3/yHydKzj8njHf2VMXkNVeZPHWkAMVSSnoonRpQOn272ZD+w2NfQFeq JHb8ZjthV7WxKAvzHTuGYLHbJBHigmPr+pn+hVkDkzvTZUsxPTZhQY7vqU6wukU9aSa6 GV5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785869; x=1721390669; 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=ILljuqyS396GZphJq1/X7QybV+ipPMbO/Gt67zfSb9g=; b=akmHN7ek5I6unQ9geLqmA6MG2hNTiGs4eUI399msqkmoAHIRNSGILq/GPp2z9vHJKQ KOVg32jts830EHIGgrriI6imKz+S57AZ6lK401VrFBWkaKNXY+eEU47c9sLr4ZpWZxSo EorzSDxvGdaXV8NyOk/RTRhFQ60nXzu64raD676I/KmAULarzgW3yXFivXtiv0nIhnKw viCsW4FnmkJVGT1sxYq7GFDXnqb9qcQpr9lsiZ4j312RzTsSsXeuucUDqvA1V51NAm9e VeE7EZGehH0mEnlg2IAroAxn8vBusPk9jLippo/85a1hFBF4Clq0B/qO0yRpWoMgcYnx MpdQ== X-Forwarded-Encrypted: i=1; AJvYcCVUvHSVD50TK1yOubOK77dtVaAwVaTcPJW4sDDbWibB09SxgqsCm2ZinOw1OSIX1llWpKWcDs75ukKCf2VeHsaqZlPHWGg= X-Gm-Message-State: AOJu0YzoGvFiIWG1fAqyT908f5wsQKH0/ZcFgXEh//jzd4caz5OivVR5 5u73rr6sN1mfaW+KmlQlH6pHVuVJAKxKFNBGK09p3l0cWKscMkhvyb/f5A== X-Google-Smtp-Source: AGHT+IFI6O177iKhevZC9TLsNEh/QLd0R6MrsRqhDKWHnTq2sivtgSjB7Hs7OAl2C4agzL2wqW3axg== X-Received: by 2002:a05:6a00:140d:b0:70b:1d25:c844 with SMTP id d2e1a72fcca58-70b43544188mr13320260b3a.14.1720785868769; Fri, 12 Jul 2024 05:04: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 Subject: [PATCH v2 15/19] ppc/pnv: Add big-core machine property Date: Fri, 12 Jul 2024 22:02:42 +1000 Message-ID: <20240712120247.477133-16-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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::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: 1720785892776116600 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 --- hw/ppc/pnv.c | 62 +++++++++++++++++++++++++++++++++++------------ hw/ppc/pnv_core.c | 2 +- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 24f7c007ce..e405d416ff 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2338,6 +2338,7 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) &error_abort); =20 pnv_core->tod_state.big_core_quirk =3D pmc->quirk_tb_big_core; + pnv_core->big_core =3D chip->big_core; =20 qdev_realize(DEVICE(pnv_core), NULL, &error_fatal); =20 @@ -2578,6 +2579,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); @@ -2629,6 +2658,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) @@ -2665,6 +2700,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) @@ -2677,22 +2723,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); diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index a96ec4e2b9..238a4cd4ab 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -296,7 +296,7 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) obj =3D object_new(typename); cpu =3D POWERPC_CPU(obj); =20 - pc->threads[i] =3D POWERPC_CPU(obj); + pc->threads[i] =3D cpu; if (cc->nr_threads > 1) { cpu->env.has_smt_siblings =3D true; } --=20 2.45.1 From nobody Sun Nov 24 18:23:40 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=1720785894; cv=none; d=zohomail.com; s=zohoarc; b=KfqMdKfUEWU00ombHv5tZaXqjnGowD8aSOkl0i/Br2VU9x117VoPv4QBri5vknIrFkNCkE8mR0ekZzcEqhKZn5kmdQTKWjvlezimDq0BUml2u4CEALv0uv3mbZ9BRDHli4rjwYEtFWRdc21/sbuRlgPaaXVJKmbgvszRLoWBKmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785894; 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=Glz2DqADEJDP1/FMyA12+YvM7zVFWvLEyd5Ky5OeaTQ=; b=dPiUMl1l54MtO43AxfIhwyYvT7D5Rqo56DIQ/lnqHcfHGEIeQukKYqs33z06LLEuKBiUUxLtDkFm7P2MLPPSd/CKA7M44iBlW94maotQXACSyRUSYlM8vaMsF4+pVZid0nq2tIXvQ424AHsf73NtwFDFZW+SfPFuazTqbOHIg4k= 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 1720785894056164.53892348603688; Fri, 12 Jul 2024 05:04:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF0y-0002WT-GA; Fri, 12 Jul 2024 08:04:41 -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 1sSF0v-0002CT-QY; Fri, 12 Jul 2024 08:04:38 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSF0t-0005sR-TW; Fri, 12 Jul 2024 08:04:37 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-70b2a0542c2so1833513b3a.3; Fri, 12 Jul 2024 05:04:35 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.04.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785874; x=1721390674; 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=Glz2DqADEJDP1/FMyA12+YvM7zVFWvLEyd5Ky5OeaTQ=; b=dIe2irl4t2XEzUx7hF9y6rRu7a8SZTU4Lv8apQNPbmWa4LCDVJBwBUg4DmbJelpvuV rhJ3tmS/KxbA1a1QBPE+pyiUxurt6pUHPDUtW+Cc0ArHw6nL3Pj97usGUmq/mf8crv8m EyiEkaXN3KVnQye7KXVez63xVSCJYLt3chPZzblH+fEwXBxcynad6kBj+ydrtwPfZinV ccPFvXBtMPT/2Mjg+ie+OoNE4mkGXQzZog2KqMcNReKYCn7vhaa2IU/m3Ic20gkMoMUR Ut7VmX1PfPcHQGEjFIdgo193PeExVkoo50D+YeoEATTwspmUjBnd8OrkZr8xAcFlxeGe iYgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785874; x=1721390674; 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=Glz2DqADEJDP1/FMyA12+YvM7zVFWvLEyd5Ky5OeaTQ=; b=d15WvGsI+QQGcgovQSL9He1VLcG8r9UgQXfEGFG4Fv21GbwNTul8CKgCli2PUi6bgD L71bqXm6hw/ViJojXIcQ99EaJo7FdFm9cl4yJYBWeVYPW3nQtyES76JRBItuyMnwzYV0 8Mu66Q9rV7W6uohMj+TO/dCXoFE0SgN15/+XPDFn+v8GqrJC/e+gXBvCUWhS5BbVdY6j 1A1tvJaKPUO6vgjsnWvssgac0OlkTRqXlmlu6hWH0kMsKTUPN5FGzONqzfau5PlE74tl 1736zgsf5WHatLKfGzkOC0DkXqV3Ou1mTRvZe6enGP1OxYTb7DCkxoKMN+qxZ5eiQrvN xAuA== X-Forwarded-Encrypted: i=1; AJvYcCXp9v6L4hrYDWCJr9OrNQG31pngo3CCZ4ro3Qfh2cpdOY701MPbobrRtEM2Ni/QzCELpaCAME6WjsoK79lgGNO+6OsJJgI= X-Gm-Message-State: AOJu0Yx8aMO/oktgKZ74T+P5nEs3yWfXb/D6qDOg7+3r0TNaQU7g07ty osTY4ERi+kK8cHx51eSy/kCCU/oGTyu33n4e5iZ082H5a5u+Xu3+7OIkHQ== X-Google-Smtp-Source: AGHT+IFcZxsBteEgx8S80szg3xNi5sqQy87RBLSLz1JW9U94SK+iPPzdTJ/8Q6jzx2V3bZA7CZ+2FA== X-Received: by 2002:a05:6a00:4f90:b0:70a:ffc7:f921 with SMTP id d2e1a72fcca58-70b435f6296mr14695383b3a.22.1720785873657; Fri, 12 Jul 2024 05:04: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?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Richard Henderson Subject: [PATCH v2 16/19] system/cpus: Add cpu_pause() function Date: Fri, 12 Jul 2024 22:02:43 +1000 Message-ID: <20240712120247.477133-17-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1720785894397116600 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(). Cc: Philippe Mathieu-Daud=C3=A9 Cc: Peter Xu Cc: Richard Henderson Signed-off-by: Nicholas Piggin Reviewed-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 Sun Nov 24 18:23:40 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=1720786006; cv=none; d=zohomail.com; s=zohoarc; b=fy8EQABxC7Qmcb+Oq1rCUAD7tDBEJYkX4eyKd9jqBjviakmMFePTsTBRX8BzVC3c19D3/Gvmn7CCCQ15+Zx/+5bGlTNwrdj8/IRJZBbJyxKscCvjNbUjuoibTXmFLpLs2zPCAJkbmSMkVc8z6s5RZUhnzNx2ObrXDQVOd3t1lr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720786006; 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=rvugC+PXW9/SGH9OMmAAj3pNBhyER7y8a5VmvcnVk/U=; b=frFZNM4zF0gkPXDIndnigUxodotDWq/odzDX8cWYYn6/WM3Upu7kRa5ChOA8ypijZiAebJ2aYJ/SXUoNg5bwYD+filjCzr7YtoWFrocyB7/nBmvx1TGvs5szvlc1AHtcd52v8XvYbrFFmokJlNnRY8zILWtGwJSEaHbTMGTB8DI= 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 1720786006521305.52368203504204; Fri, 12 Jul 2024 05:06:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF16-0002ps-3T; Fri, 12 Jul 2024 08:04:48 -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 1sSF0z-0002dE-PX; Fri, 12 Jul 2024 08:04:41 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSF0x-0005tX-U5; Fri, 12 Jul 2024 08:04:41 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-70b702be5e4so334679b3a.0; Fri, 12 Jul 2024 05:04:39 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785878; x=1721390678; 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=rvugC+PXW9/SGH9OMmAAj3pNBhyER7y8a5VmvcnVk/U=; b=Yi7K7CXr7Cvjx1kgpNyVOI1JqtWuamBb4h9lUqP7HJx58ks0WqDcndctLQnN8C+KMG SLzqz2qZf34MrArhI4koLF17VzRf2D/h0MfnaBh/il3or3OlfmTmD9lsnBtuhuKbI5dI lFPSXVWA9wj+QaBtL+NHMqN6h7TQFJy20EYm4tB365BIqQ/UensMlWoH+HXHdpwa/hLf ZXIdb9rDzL38+RvdW+CpDdUcWHeF+4jM5Y+RUgfmcC/kI+qbxNaJij1aNfDFlHYv6Y59 II+QNHJpwTNOHWLOeoEeHJElK/r/71W0HQ889j7R3LgTVQ+9snR06Egjj8bw5eMqu1Vk 6wLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785878; x=1721390678; 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=rvugC+PXW9/SGH9OMmAAj3pNBhyER7y8a5VmvcnVk/U=; b=n2U3tVldFgNvHPxt5UZududQ5cqO1G5dhd4BxlbGwE2wAF25GPrIu7MZzKDvflRBB2 CsOqsLhsn6lYIbkANrXJ8budLQLV4xNt+Q6y8AJHmFZKN548qE7OBwgKDLvgz7B7vnj6 WlCunxz9ksP1yg2T+iyVmc/VUuh0w4IL6436s0s3BofrEJU+KXxumtAz8qvU5sZFN92r Q1kclRzz4Dl7S17u/0XvX4IkGZ+y7kybJ+XdYTu9kz9BPzqfLQD652m1xSjIyPzQqq6M yjJLjsT/ifYQrEJRAy8QK361+LFqRBLzX+tXGY5RkGj4M2bDZGYkPU7atcK/BOirOLQn b++A== X-Forwarded-Encrypted: i=1; AJvYcCUqFXRFmdSfTCz81OJ1AG89qzD1R3MCu1T9eaV11p5dE79LjZdUYvPa09jUwVjCxEDextfX1QkMwAl/iG1S1JDf5YTaTqk= X-Gm-Message-State: AOJu0Yyw2P7XWXoztVkffgY3MHGU+kNloYZWp9lUhJhtcbDIOkmR2UCc ESqkjy7kZ6nK7qjk/qV15crurErFYHJam51aPoHpbZV1l1W95ndy9qJ0tA== X-Google-Smtp-Source: AGHT+IGXakIlgwxW4ufbgqrF+m7wat1y2+yfd1cXnUIdYukAVCKolgcyLuDABEGkZQ7nUsqESRxlsA== X-Received: by 2002:a05:6a00:21cd:b0:70a:f38c:74ba with SMTP id d2e1a72fcca58-70b435eaa3fmr13720110b3a.22.1720785877737; Fri, 12 Jul 2024 05:04:37 -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 v2 17/19] ppc/pnv: Add a CPU nmi and resume function Date: Fri, 12 Jul 2024 22:02:44 +1000 Message-ID: <20240712120247.477133-18-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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::429; envelope-from=npiggin@gmail.com; helo=mail-pf1-x429.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: 1720786007044116600 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- 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 e405d416ff..cd96cde6c9 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2749,11 +2749,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 Sun Nov 24 18:23:40 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=1720785919; cv=none; d=zohomail.com; s=zohoarc; b=VRZTvHY23coDz5ywdig8mwNNbF935ZGk6Zm0JevoRTqUA7mxPHfusfidt9qmOtpidzsZClQdFJgTC2ay7OeSNbGxtxZvAXX6l/9/zM/Be9hAl5qGU8hHeIjVbIaTZ1IVYTc5ab0w/mV8/Y+pfrnNkrhvfiUBtzEXh3SrxWLQFrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785919; 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=VSdEx+3/IO385nx55P7iJ1IKkfoDSyJ7uSRZgpIc/C0=; b=M70Iwf6slZ9RgilPLYdcAk2s0iMH2mLFGJ9+QIWonmxHF4D/REDF2vxGoNMCMlVrSiv8K9as2eS6HD5g5D/QGr7xR5S0ddtaTFQ3d8G1xrIT+xowTCgjH8Reb6oL5/jXQq/vi+n8XrmT/PHvPqdiqDz+5YCM9P6Jo9oJmXrWp3U= 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 1720785919038194.91407943418665; Fri, 12 Jul 2024 05:05:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF1B-0003mA-4Y; Fri, 12 Jul 2024 08:04:53 -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 1sSF17-0003Lh-Sh; Fri, 12 Jul 2024 08:04:49 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSF15-0005tv-Mb; Fri, 12 Jul 2024 08:04:49 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-706a1711ee5so1522023b3a.0; Fri, 12 Jul 2024 05:04:42 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.04.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785881; x=1721390681; 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=VSdEx+3/IO385nx55P7iJ1IKkfoDSyJ7uSRZgpIc/C0=; b=X15w63TPxn7ypbykiyfKEqdkftaQGUb3mjJF8OMgP/cyAUMxM6OcY4ZOBEO1VmcE5Z 4YxqiulnGvrB3a8JCnVvmUsOCFj19jjLItrlv2eTncgfDIZDSsGWU9rs1NuGG3txJlJs JCs+zDiEGw4p9ms8jndNmBlk22s4YRc3qRpbwliuqgCFl8uL7OdsfSFXuzA9iwDJkb2P ON6oIYdgw5XstZLdz8b9x2wmAwETZS43OVyvQPLBXhSRUA4UrLJfHgBH1/WWTOEaa5bp +rfODnO7LX+D399T2EmJNcgQxPA1OyVP1HAJnNF1WYt3Qcm8z+q/BH/hm8d92vBUx8oR rV8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785881; x=1721390681; 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=VSdEx+3/IO385nx55P7iJ1IKkfoDSyJ7uSRZgpIc/C0=; b=caLZ0EE9f8BeOph8TUITFAPDCw3RlrbCrTQlFigLOX3x/GjmSHliabUtTVBMroGU7C ArTrAEPtsRSZTK26aeYHL4dN4fynAsj/i9blxQget8zJ0a/XSOaoCcZ6INtt0zSEjSmb /lpwXoe98boucWjGw9oUPInL1BDCkiTVhReqBaWiTpA/0lL2XqF6drod0sSMntiY3w5H TVA2cbPKvw+zpADSVctPIK8ydXrbTdqTNfR5TEg9ZWp96ZSN6gX3OLX+o70BGOJHvWKb cL/MspA/0c0sqchzarsBE+nIEXE6VGR711QDDAbTwlZjU/3e1r8V/wkYZJlTtPblG7n7 /yxw== X-Forwarded-Encrypted: i=1; AJvYcCXsZv+F74Mxxtd739vZoy08exw+rw6ZO4qzAB5Bc3u4YYR9+cel16mSCcPxE6z2Zg+cHQu2ixKiHRckF4QOCC0HLAtMmeI= X-Gm-Message-State: AOJu0Yx1Mtvjm4FkQlOVO0bvwesJA9j911GFCT3o1RNzUYqQqyqgnfMN G/bT/lBTP+uIlv5/yLNQW5tXRWbha4ULUtwpmgqyh8+2uO1gNKHDkUBwrA== X-Google-Smtp-Source: AGHT+IELspR74/6dYvT9ljitdMkm0/xOp5sVLkZomCv0/PRjAL7glY62JVPwyRYqcjlPGjigN+ld4Q== X-Received: by 2002:a05:6a21:33a7:b0:1c2:8cf4:7656 with SMTP id adf61e73a8af0-1c29820ed84mr13632265637.10.1720785881466; Fri, 12 Jul 2024 05:04:41 -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 v2 18/19] ppc/pnv: Implement POWER10 PC xscom registers for direct controls Date: Fri, 12 Jul 2024 22:02:45 +1000 Message-ID: <20240712120247.477133-19-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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::435; envelope-from=npiggin@gmail.com; helo=mail-pf1-x435.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: 1720785920616116600 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 238a4cd4ab..b32bdb79ff 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); @@ -523,6 +584,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 @@ -530,10 +592,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); @@ -545,9 +611,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 Sun Nov 24 18:23:40 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=1720785926; cv=none; d=zohomail.com; s=zohoarc; b=BiRjzfFheFz94mwN+nJVOK2i418Y+Hy9S/vKTh0OEvHN5iAXAtCQj7vZTfBH7qLAOoPRoQpd+P1lfARX++KpkjfCMUP3r/udWkvmgjGjOV8akqmIV3gkw2pVyDGV74AOAIlf5EEsoKPeMYJqpu+uL7AAElJZw5NkW/pHVpdwXUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720785926; 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=SXdn44hAbdq5BulP9IKwZ6DBrTC0S7IcN1mxi7E3K6g=; b=fAb79HrIAGLoBiyELBq6LnZ1BvUVVaRod7UHraEKYnLOzJQ0bpuKYC+illH9zvoLW8LvtfFBgzPnBoiC+iZzkvGdb8KUdi48E+wW9DRyGiAcvtpckC459hVekY+XebByFQ97J2t7vVUsfvAwdFoo3dHbMwapObgOFsoZqmfIJO8= 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 1720785926371532.7717006591367; Fri, 12 Jul 2024 05:05:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSF1G-0004QV-9d; Fri, 12 Jul 2024 08:04:58 -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 1sSF18-0003Vq-TC; Fri, 12 Jul 2024 08:04:51 -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 1sSF16-0005ud-ME; Fri, 12 Jul 2024 08:04:50 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-70b48dfd6a2so1621319b3a.1; Fri, 12 Jul 2024 05:04:47 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b438c0a1csm7308967b3a.63.2024.07.12.05.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 05:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720785885; x=1721390685; 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=SXdn44hAbdq5BulP9IKwZ6DBrTC0S7IcN1mxi7E3K6g=; b=AlyhGtOmhgtWNYwj/fvMQO4v0S+JRwTCTmyoyApAxGAE2/FRkDIGuN4HdwwspI1IeX 6folbOlKHX7BdgFnaJE08OAdkmEKmlBv++XF6qQuTXPdm/uFLczgV7+5iX0ZTU1QE3us mNNT+vXyhYGz9SWnfrabcpCVp6KFpYKdNOJ55L8tHM9eLfSb8xf87X2FCpSQHWLXH6tI pKNXuwNRAhQZG6c58h6/Uuk/V864R28+aBtShJHMH1R3TsEiSlyt12Vgp5AXeglbdgSZ QLq1wDWErpFoV0Ez5YfeXveuHrQJxeYuffNmiWO+cecZ7KaeFn4l4LHJMrjK5+i6cVd6 KEJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720785885; x=1721390685; 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=SXdn44hAbdq5BulP9IKwZ6DBrTC0S7IcN1mxi7E3K6g=; b=K4FZ+LXth4zCpd0ybMVbUzKm99rfnLKAwLdBQjiDo78DvR7FksY6FTZ/qz89DFI6Pm SmIDSQc3mZcdE0pQbu5P6ym9Yt2BFM1tUzqLpR0VKY7njVuxLGqUGGzDNOBPMb7Zld9S R7evdgM7myEfgYXFQAtEOzW+iyXn3c55oUKOiuLUnCB6vXxyFTeBcWyaFpTAyhASTYSy n3u200025SDXgJc+isKkeXLa0JEvzzciNnAy2SS3t/Cxc3O/ZsqpjesmAk65a/f80K90 7tLdx7LaawSuN90j8A9lBoTHXtU9Xjmd8JZNPLTJVYoJ+WJP8NqIbYmW4G7ul4y4bGtH 8lNg== X-Forwarded-Encrypted: i=1; AJvYcCWwaxETHT1Za0XyOl44ZO4xvzw+d1CAtsWukr4BTpXZgRk1V+4TAnlnm8YGOuIUqVj7v4sCdsZkIsDyCiD41iVbLjgcb4I= X-Gm-Message-State: AOJu0Yy/5UhU/FCPOm5WKal0QxzqQL3ItadBA1AaTcC5q5Qrt1ijn4Fv lQggrgDB8lUWJMF5v5Z2GPTLz6tfBSgc5nAJWS2oUv1wWLEKOgt7O+CWkg== X-Google-Smtp-Source: AGHT+IHdnfp8DpkdxhiX1YTZJQ488E3ZtEerYClUb/ad4IYNbUzBpYjEDUy280v+XSkXkQh/23HIMg== X-Received: by 2002:a05:6a20:918d:b0:1be:c5ab:7388 with SMTP id adf61e73a8af0-1c298220a18mr13139010637.25.1720785885280; Fri, 12 Jul 2024 05:04:45 -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 v2 19/19] ppc/pnv: Add an LPAR per core machine option Date: Fri, 12 Jul 2024 22:02:46 +1000 Message-ID: <20240712120247.477133-20-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240712120247.477133-1-npiggin@gmail.com> References: <20240712120247.477133-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, 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: 1720785926678116600 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 --- include/hw/ppc/pnv.h | 2 ++ include/hw/ppc/pnv_chip.h | 1 + include/hw/ppc/pnv_core.h | 1 + hw/ppc/pnv.c | 35 +++++++++++++++++++++++++++++++++++ hw/ppc/pnv_core.c | 7 +++++++ target/ppc/cpu_init.c | 3 ++- 6 files changed, 48 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 cd96cde6c9..be1a48d2cb 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 @@ -2308,6 +2313,7 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) } =20 chip->big_core =3D pnv->big_core; + chip->lpar_per_core =3D pnv->lpar_per_core; =20 chip->cores =3D g_new0(PnvCore *, chip->nr_cores); =20 @@ -2339,6 +2345,7 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) =20 pnv_core->tod_state.big_core_quirk =3D pmc->quirk_tb_big_core; pnv_core->big_core =3D chip->big_core; + pnv_core->lpar_per_core =3D chip->lpar_per_core; =20 qdev_realize(DEVICE(pnv_core), NULL, &error_fatal); =20 @@ -2591,6 +2598,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); @@ -2630,6 +2649,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); } @@ -2655,6 +2676,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); @@ -2664,6 +2686,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) @@ -2686,6 +2714,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 @@ -2711,6 +2740,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 b32bdb79ff..d59da16ce4 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); } 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