From nobody Sun Nov 24 19:05:44 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=1720707582; cv=none; d=zohomail.com; s=zohoarc; b=jsuGHPZQ8iQyg0ECZeWA296mI/A7lHShweHVEldJb5rg7+1+g4T0M0K/nWPr9YefV/F0DAU6Ugw1AgRHGDnEF39psx2g6AEEIEBuYiPdAo3N1fpMyIrx+ZHt0AX+EdCqmmPLxb83hZ/xNafRRrfdwdUPVy1PlNRXjOSgo0Pe/P8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707582; 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=TAH4O1NHOlM3uAyWb3ssMGd5UxeSj6AOHrFW8OMEk8Q=; b=F7t3gmDJ4hYz0ZZB7zwRkdgqpxvLyPYqAGsEJSrjCr92FCgtny+g5oIlIx5gDyobn0vQ7BaKCxwlscCaLsK6xXBoOsu5j5vX6uhInl3SJ78E4gMAEtpQB+/6IpQp+d8HZlYQJiJYAR4mEIJudZ3FY7K4Uwhf4a34z7PfvsYVs84= 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 1720707582494588.3517713782909; Thu, 11 Jul 2024 07:19:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRudZ-0002T8-07; Thu, 11 Jul 2024 10:19:09 -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 1sRudX-0002Md-Dm; Thu, 11 Jul 2024 10:19:07 -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 1sRudV-0005RJ-Mr; Thu, 11 Jul 2024 10:19:07 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-70b5117ae06so758847b3a.2; Thu, 11 Jul 2024 07:19:05 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707543; x=1721312343; 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=TAH4O1NHOlM3uAyWb3ssMGd5UxeSj6AOHrFW8OMEk8Q=; b=LcFrO3/AqYLgUR0tZ2Oy0kw1bLuk4BOH7XADeE490wXYBD8HfWTmSQDkvReJOFYHM6 +9xGuB4KetZXiO8eh251fTscx2aMO2skDwapY2etsOAVYqW8DLX17VC2g68sRMYG5Hz0 qwGoUNkGeBOzv1zsz1ByzTJSHQc6GRCJjaOJfIAO6Vt5ft/tNo0541su7f7eAUd8q1Js Qd2zJy+99MeLb2AQ4zaarCbhwwaLRQM+eyC2tE4ttzFwa+2iANYHYGU2m5sdmJnup5ml 4ka+epMO6lVxEm5OzMPG+qq4Oup0GlvLGeBat1gJEAWtWGo07DHrxupLhcmMbblp2nhW HJSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707543; x=1721312343; 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=TAH4O1NHOlM3uAyWb3ssMGd5UxeSj6AOHrFW8OMEk8Q=; b=ll5Rrqgnomawew1YkQ3sqCD39oeSz84Dqqgwjam7QQCGQPy5fadGEIR6IUF0eGjGBe RIxRlHxJxdJf0cPyRGcnpqqtAXZq7gyaS7LuLOJlEVMZhI2FtfkaljDv+kJlZFE/fPS6 2HIlugfHVlqj2c3DzN8Wx5aBa2K7dp/7X/abs2ZlCkl5GqrxILQ49Kyq+7P9rbtnFxOS q3CvS094FY3xHuDvYyTL/NI9HTytcLP37JN3QefgmW26TEN0vBglYKYYSlFBjyUacKF4 7IR2rr3cpf0ZqHeVx/xYKV6PL/jBoeJqZvs5MAMWEr54KIr+ktzX0JPx35td81q/q+Dl RIrQ== X-Forwarded-Encrypted: i=1; AJvYcCUWOLRU0MCZxrEFxd5Lb/YecjVP5eqS178RMNWKulQkHGMWeTX9Pz8O0bnSlUKfyzNktvZh1cCBq/Jhx3XbCRe6iUzY72s= X-Gm-Message-State: AOJu0Yx8Gyy9AeYGfpMJp6tMWRQRZ6WKwfKh2Dw9AoknBssgkgR+pnY+ xIc0Qx30TtAt7cTahtWiTXCpuCmvG7We8fPACHuu9dx9BzDecHYVqe7gnCjw X-Google-Smtp-Source: AGHT+IF2+ZSKlwHmev7lpGiIX59OgDJfTQy/wJex4iRY8oXYM/UMchkdnxkbL/kDPVKoGsnlqBXYGw== X-Received: by 2002:a05:6a20:3ba7:b0:1bd:2894:4015 with SMTP id adf61e73a8af0-1c2984c85b3mr7632762637.50.1720707543352; Thu, 11 Jul 2024 07:19:03 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH 01/18] target/ppc: Fix msgsnd for POWER8 Date: Fri, 12 Jul 2024 00:18:33 +1000 Message-ID: <20240711141851.406677-2-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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: 1720707584276116600 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. Tested-by: C=C3=A9dric Le Goater --- target/ppc/excp_helper.c | 74 ++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 0cd542675f..c0120c8a88 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -2998,6 +2998,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)) { @@ -3018,6 +3053,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; @@ -3064,41 +3106,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 19:05:44 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=1720707747; cv=none; d=zohomail.com; s=zohoarc; b=MscMqqdovgI54rHp9Uv3abdCf3cjc/TffRsXg4kuJPKwSFAkger3ss8Xu2iRGbxW4cfxLrZkfC08WaOay/MiEqej2YmQMgKB1Hyt6I5wZOvP/tUdgiKYhv5SB6BoC5plH40zZoOyTmC9wDhtBr/UaEndqvqQaBHadUDvf0sWxX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707747; 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=GRU76POH7d/1mRnmY/qfVNC6Ibq6GlDp4Uhj+igTSNsFEPpcXEvx1dIpG38GpX7XEmA9eW1fmBukLkepyUY1Om+X2Tr51SXz7me9R7sYJd+oHl31UUQCkFx/Gsg/R7BOtYsC0wePuso2mRcwU6b3Uh8toJ+S+uLXezThxuTiRtM= 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 1720707747321719.2655600640696; Thu, 11 Jul 2024 07:22:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRudh-00030j-Ag; Thu, 11 Jul 2024 10:19:17 -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 1sRudf-0002ss-4z; Thu, 11 Jul 2024 10:19:15 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRudd-0005Rd-Jb; Thu, 11 Jul 2024 10:19:14 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-70b6003c3d2so633769b3a.0; Thu, 11 Jul 2024 07:19:11 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707550; x=1721312350; 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=HzUBqwLPr9vArabkZWIizULY7uwz/vFZFgQRhL1a/ULPwF8MMmLRqMsrCz/9Xx+q8l tXUl4UxjJPD15q/4lBqYJpEzSiJ4STezkpNaCC5Z9Z9dROv2b5LuoXUUUJEGU2+Mb6wZ ibxnewmpoHLmjoD3CxoiDvtLTcGdSXTqNUUZBWo6qmhOWZs6KMwqs24B6WZSi3Muq0nZ jPTLbMGs3SLr22/ASjY5cze0C2K9/RwvblgLdvN42zTYcCIhvLRy8D5SVKbKFL/sB/N7 gcBZE8qI3dYooUXrHrS+pagPXsy66ClEI7XQqn5yc6G9GxCJQ3+K4isSJqEnfqV+znW2 pEXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707550; x=1721312350; 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=MSf5pjbyyPRMlRfwUyQh/zMFQFP/xhU3YVliDkwdWL6GA3f9dgrT5PXDq7b017A1MF g4JDR4TwIKNhGk2sFkvYOAVANtz6DA5ys5ESQisWG7u8O/jzoOWSQET57lz9FFCOC+MP 6YNNGfL1I93ucT0/tBJSWkGWtGKEZR4hl6wXCOm+yorGIu/zTJNpoRnUMeoU4GeyRcQ2 +5hh/DTVKWbm6GzRPxrMhNTa66yQzjveeC/kL5v8KRCvY2o+wDklwsJeA99MsJYbWGKK OqZPasmn0Pc51R078/haKsy1k/8CoPp2HSphWTzeK8bUqdWLZgPnINQn/BVT5HQSrSl/ Pc3g== X-Forwarded-Encrypted: i=1; AJvYcCWV0IyUMSh1DVCaBl8fC7FiYKeKobq8ud1qaL2TrhEo9/2wXOF2+HRPaox3eD21vWqrQDSXn1X8mfBP/BLBEE7uWBYeq2A= X-Gm-Message-State: AOJu0YzBmo1q4fuGT9zD+mwasyPsMBmxqyaDEX4r1gl7tL9Uu9Qm96oT ULV8ax+up3DlaVLibKm7iTshVm8/z5PtyY/6iVFejDjIfaNwX6R1y4Bo4L3j X-Google-Smtp-Source: AGHT+IEklDeaqTNY8/incWvI8MIqhlhhVgYrQDVIMhozgbGm3pC2G7+pFNCAW/iJDtJAJ3zCpdRmiQ== X-Received: by 2002:a05:6a00:1ca2:b0:70b:17df:cbc1 with SMTP id d2e1a72fcca58-70b4361b82amr9217369b3a.30.1720707549695; Thu, 11 Jul 2024 07:19: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, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 02/18] ppc/pnv: Add pointer from PnvCPUState to PnvCore Date: Fri, 12 Jul 2024 00:18:34 +1000 Message-ID: <20240711141851.406677-3-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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::433; envelope-from=npiggin@gmail.com; helo=mail-pf1-x433.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: 1720707749191116600 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 Tested-by: C=C3=A9dric Le Goater --- 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 19:05:44 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=1720707583; cv=none; d=zohomail.com; s=zohoarc; b=ASQwusjKcYiv/3e4EwadMV+R1pf6nK7HKQTjXpBgiAFREYv7r/yjOavLN0azKoFjnAZsPh7ufweGF4dgenaqeNY4Z06IoOn1XI6Z0PjL87VDJYvEm104siH86DvJjj4KuQQO3nlT2fJpKlybAGlFcUS08UxOWkgWS+aVkR2dgJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707583; 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=k/0JQNiQg7zbx/VBkr1CcWf+JFBJuc5tZvRHhkhIoiY=; b=nE13an0NPw1XFa5uJEfqpYqlk33BaXOa0VEmyrRKhSaM/o3z81WSGuocGF8+EUdokTgxrAdDUBhnH5dOQTHGPiWmkxG8WsZ9xoM2sr8NM/2kKpZGIsGbRrFwmongEyYgUEWSnFd8VX/8/nCl3maY5wKszq4GwGs9yTI3xsf1Wok= 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 1720707583495403.80228613542613; Thu, 11 Jul 2024 07:19:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRudj-00037o-16; Thu, 11 Jul 2024 10:19:19 -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 1sRudh-00030W-8J; Thu, 11 Jul 2024 10:19:17 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRudf-0005Rz-Pu; Thu, 11 Jul 2024 10:19:16 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-70af3d9169bso860182b3a.1; Thu, 11 Jul 2024 07:19:15 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707553; x=1721312353; 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=k/0JQNiQg7zbx/VBkr1CcWf+JFBJuc5tZvRHhkhIoiY=; b=FM8c7SRBfQVrREweoXnTMOLORhgolGp/Qi1BpomHqmnCN0JDp6GnZ+5bHqlz6jyre8 eeFDtBHl111MT4ivwQBB4C4c8VjsP/g94BgRlDno8Ux4ysdG+lZd2KknWmh33Eibt/IP 6qF5Jbv8Y6x5OTfTeUOpQt+HlMYVu7zO/R+0EETpBK+Qa5Bq6yDC41SFP6tNhki+VOwF KibDQx3h5Sw4pGxq+v2FjRcwaml674kNYg3IqZxzW706TY04qMM/ord+kfiO24oJfWBE pgEzNZOqVUq57AHB0uBnVsBUlpg5kBJktwCLqwTiFxVnyxPFEDxp5MRCvJAXdeeSn6aP 5gtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707553; x=1721312353; 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=k/0JQNiQg7zbx/VBkr1CcWf+JFBJuc5tZvRHhkhIoiY=; b=Mb5gHIgSlsP7RYbygeaz9TSsq04lKe9/+jdC5tg1wJfm+d68oCpbCc27KE2g+iPYFC +fqzpxyU6L6HdC3jCDlPSWP+L1XUahj53Cv39uAK/+GP2dytiXtizXGD0NQ1ZxC4CgjI f4L+quxxGYzYhAQ0j4gxYE+2NCXCW2YOJCiMNQje6OrZX/n+JP0FeBAY6+zSz1bXygT6 I9LPJ63uFriqm1WMxZ6usobX8GALNjkMlBv+wntd2eYB8X67aOf2n5vVj4kTqqYsfOeC 11f/6N4IHDg5i6U6xdCwtkjMzF9JU48a8jdUl7kMp5ZbLtXY7GfFK0jsLhS/+ovP9k2m ebIg== X-Forwarded-Encrypted: i=1; AJvYcCVUfoiB0ubF48/RUV8DP27veDdpRWWjpMmG2dv4HCw45+z8Xrpn754LE78ARz1j9dj19jlTxITHJXdWTGcAempNC27je9U= X-Gm-Message-State: AOJu0Yz5mgVCk4zvU79PE3dxHpJu3EQLwDLdYt7Lobcsh7bK/jnajPXP eLrch+DOQF0SA+i16jbaFzLwoDDITG4mnrCQWWv34K0fPhNTFNQSqZnoCfRj X-Google-Smtp-Source: AGHT+IEHK9hFKCMVXA2i3/XqteYTJn1Byq7QkglNbkLE0opkdHddDU6L82lJ+qFWl4tigtF5IZkzlQ== X-Received: by 2002:a05:6a00:a27:b0:704:2bdd:82fe with SMTP id d2e1a72fcca58-70b4356c534mr9166117b3a.15.1720707553286; Thu, 11 Jul 2024 07:19: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 03/18] ppc/pnv: Add a pointer from PnvChip to PnvMachineState Date: Fri, 12 Jul 2024 00:18:35 +1000 Message-ID: <20240711141851.406677-4-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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::42c; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1720707584262116600 Content-Type: text/plain; charset="utf-8" This helps avoid qdev_get_machine() calls. Signed-off-by: Nicholas Piggin Tested-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv_chip.h | 2 ++ hw/ppc/pnv.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/hw/ppc/pnv_chip.h b/include/hw/ppc/pnv_chip.h index 4eaa7d3999..decfbc0ff7 100644 --- a/include/hw/ppc/pnv_chip.h +++ b/include/hw/ppc/pnv_chip.h @@ -23,6 +23,8 @@ struct PnvChip { SysBusDevice parent_obj; =20 /*< public >*/ + PnvMachineState *pnv_machine; + uint32_t chip_id; uint64_t ram_start; uint64_t ram_size; diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 7878fed43c..3bcf11984c 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2202,6 +2202,7 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) return; } =20 + chip->pnv_machine =3D pnv; 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) @@ -2614,7 +2615,7 @@ static void pnv_cpu_do_nmi(PnvChip *chip, PowerPCCPU = *cpu, void *opaque) =20 static void pnv_nmi(NMIState *n, int cpu_index, Error **errp) { - PnvMachineState *pnv =3D PNV_MACHINE(qdev_get_machine()); + PnvMachineState *pnv =3D PNV_MACHINE(n); int i; =20 for (i =3D 0; i < pnv->num_chips; i++) { --=20 2.45.1 From nobody Sun Nov 24 19:05:44 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=1720707599; cv=none; d=zohomail.com; s=zohoarc; b=LWYGsVFp+QURvLDZrBbCXOIM63fYjKD0hTL1GW/lejbL8OGaJl1cwFNklELCrnPbvh5NnWmcVDw33Ah+WJryD2WWacK9Vgw+DhBVucUVnKkYd1MZXE7wH0GgkKfhStcyAQXPnynnDZfSaCVnSjrzQFj4KFonPppCh7RVU85bgg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707599; 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=IF+Z0rooVKcgTIkCLv4r7CuQ9e53hP3jLrEaXKBu0P86XmGLfXs0hQsptJXDcHs9q4I1Mxxk4sfbvAntvglFzYKL+RigUQ3nuwtAaE75dEvNkM4P7MO+aBmSKvTP5d4cpQob6ZLmBTCQdMe/2l/vm2gNA5r7IVYh870w4IYKd1w= 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 1720707599683126.55142765190305; Thu, 11 Jul 2024 07:19:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRudo-0003TG-Qb; Thu, 11 Jul 2024 10:19: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 1sRudm-0003Lf-Kw; Thu, 11 Jul 2024 10:19:22 -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 1sRudk-0005SP-Gy; Thu, 11 Jul 2024 10:19:22 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-70b6003c3d2so633928b3a.0; Thu, 11 Jul 2024 07:19:19 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707557; x=1721312357; 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=TLmOf9+xJRSwh7O9fCwPDUAsPIroZWX5gPXkELe0CvgDjPRuYs7LlbgyE2P2NVH8xn QivfrbFZQhUT2wBMJxNJTOg5KuzXdXcbsprua18lg/LExm38la/OBpCGr5gGXRTUP+/F BLkEep5G1eF62g5TK+GaxscWhnho0Eq5MRFx59ilsVB8jbWG5IeNOWdo0sEdrhkQzAzW LW4hprRfCRqrRCdbK7qJdLbb82vwfVg+iGPlkzSkas6xnISVG9nBhGP/QvvjuhaRiIA5 iVcgv860N340JoGeXoKBb+ezLfODhSGOZvoQXYvk1wS6pQaIV9KCw+NBSw8VjVGwzh86 wYqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707557; x=1721312357; 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=Cad4ERMdGbhBLBw/D/BvZlTCj+SbvAZ+fsvp5Xu2FdxKn2ud+X0DKnPDv7OtIEFAgK vn8omFNzA62yMBgR/7n4OccD7VtQ92TzGdRRSpils/ScyE+oILUXGI9bH/2fGnj3VaPb Ci4+2kbiWsZP+TAyddAB31b12kcHEXC67xzYSPUTJXYPYpNEjAUcL5BkfYmjtHAdznvu sa/98fw4vUE+8JNYb7lk5XXKn1JPkWWFhrYOsXqM3PCryQmsz9tyKoeLi/2uoGMgB2Zk lZlCi8gCZ1gJrWoiIRUSjRJyozW06H1QYDpixJwCIdFq12hxZ3QXXO5Y90mEPp1sa7qJ hWTA== X-Forwarded-Encrypted: i=1; AJvYcCVuVeLfg/mHeokgmCyxiRsIbWr+t3wqD57FNkmqb3mCn10d9xLXaQduPt20ut44nMXs5oBGjdCSPk2Rm0aT6qPTeJq0ttE= X-Gm-Message-State: AOJu0YykSvkQTXwiBExCaA6iyIIYSv0EXP87NYNg6Cx2iPMoK00Wb5Jx tIJmFfdr6IvfArPfU6YTIyahoeYAZmkiB+pTZiJVkV0Lzwrx9NUhEkToLVs2 X-Google-Smtp-Source: AGHT+IGjXq/Tmre/i7tbIiX5RgqIize548vW4hlf10KMbCBVpHyELaly+a97/Ll7GjXqB+8sRvDrsg== X-Received: by 2002:a05:6a00:1ca2:b0:70b:17df:cbc1 with SMTP id d2e1a72fcca58-70b4361b82amr9217794b3a.30.1720707556963; Thu, 11 Jul 2024 07:19: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 Subject: [PATCH 04/18] ppc/pnv: Move timebase state into PnvCore Date: Fri, 12 Jul 2024 00:18:36 +1000 Message-ID: <20240711141851.406677-5-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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: 1720707600394116600 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 Tested-by: C=C3=A9dric Le Goater --- 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 19:05:44 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=1720707703; cv=none; d=zohomail.com; s=zohoarc; b=oAnz1mTXKkmefROjBYrEQ2rFtLJ0kIqKD5ak1j8EIJOa9mlYjBdKuZ6MEvkX3yDoo59Gc5D3ODMLe4iY7fp4nFw5N1Li9iIbO2bWMsDKt4rrWvtiuHQInewI4MI9Z+CqJSlDkRY5WlfjWHBJXOezH/wKr6WqoofPpcCOWQfImbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707703; 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=Wf9tMV0G6CWSuDk9c0gqJneDtjrYGfaaQZm9hCAo2Ow=; b=hqwAm7EWRRafjIv3gRzXBIP82nEmfvehtaPeW6uwq//ManTQAITtgW72uYspquh32xovPi5ADt1gin7TXjSmBWzfL9JsIyz0SniZb2xY5dNUhHSDRenpKY13iWVmHD8HaYy3+RlzEtWuEJCt7QkPujBf7v2RPAnUnBT+UVVpU8E= 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 1720707703888520.7450152297099; Thu, 11 Jul 2024 07:21:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRudr-0003cE-BE; Thu, 11 Jul 2024 10:19: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 1sRudo-0003Tl-VJ; Thu, 11 Jul 2024 10:19:24 -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 1sRudm-0005Tt-Vh; Thu, 11 Jul 2024 10:19:24 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-70b03ffbb3aso825297b3a.0; Thu, 11 Jul 2024 07:19:22 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707561; x=1721312361; 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=Wf9tMV0G6CWSuDk9c0gqJneDtjrYGfaaQZm9hCAo2Ow=; b=N6BbNuOaaJMBN/tBSKJhArwPw5959Q9vf/W117sCss1D4ORSUHRapFrehBa1DF5m13 LpPcMDcCPYllyQ9lQcmWcD1b+lH1i5W1YYrIjn73fqkLbua4vWBG8iX6oG3VqEXbzucG mZRN3aYmI9hSFMuUNJlBoW85KkkcG2HRN7WZhv2VbAi80QYePv+ozwEN0PFy467MNp9W e5VCnHi7Xr3lyMvQQSH8PNdpaLQFcXrYNY2ryr46Rp763QfhKRpUikCcYrAy6KPDhLae Dr6TLJKG+OdJ2PEGuD7sJgQ+qRFOP+NMQWrFHkcpxl8WwCr4J1jKVcirdcLeUCDlJS33 GxLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707561; x=1721312361; 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=Wf9tMV0G6CWSuDk9c0gqJneDtjrYGfaaQZm9hCAo2Ow=; b=ExVDyT66Jw/uKjRHlEj3BG/IHtV2dSGn7T4GSL5+XvJCBY6M+rOdhj3TWY8iXEbOOc QJAzMuoXQ/sogrTYKxjhinxFK9VYcs3PzDy+dOReIdKFhgwnMVud840ZVA8BQ0tmdP7n Gra7UWggJUzwwGhdc9p0vEm8b7t/qMPw/siKb70uFRbEDitko7IXGdkDRzwjNIOpAn4F SHKq2hVE6XZsDv59PhWxLDd7H7/7Tr6XKJcp0vEP9J46hkR8Vt/+kV8zMnYW/LgGYtFT k3yLjF4lHvY7ay8vTDqq+krv3c2deMFNJTXd1KBhl/y5F74w/ypyP/vwPPCIAOs3kU8h /16A== X-Forwarded-Encrypted: i=1; AJvYcCVAh1fOS/ettAzOsjPdO5oN89NXjwNL9aPz/Om1qXGFeeOqiTGSjzh+GylzjKbvOhU42I3VbsynaMPConYQEN1VFojNayU= X-Gm-Message-State: AOJu0YzdC8S19l87d0aHrkzXZysZWWAMXcCQvib+dsp+NLZlmV6EOZzn 0yMMC/NqnLB9RhxazxpshyInwaTMTTuKqjhOMB0kZ4EvooOMCCpSJOH6pHZr X-Google-Smtp-Source: AGHT+IEb/vpSqZkffW9TshJaA3DjmH9tL5KN3em9vI0lMd3Ql1HXcm6HBotavbnC1RxkNMOaNrCr3A== X-Received: by 2002:a05:6a00:2e18:b0:706:750c:8dda with SMTP id d2e1a72fcca58-70b54e8a832mr5228883b3a.6.1720707560534; Thu, 11 Jul 2024 07:19:20 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH 05/18] target/ppc: Move SPR indirect registers into PnvCore Date: Fri, 12 Jul 2024 00:18:37 +1000 Message-ID: <20240711141851.406677-6-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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: 1720707704911116600 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 Tested-by: C=C3=A9dric Le Goater --- 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 01e358a4a5..ae483e20c4 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -5759,16 +5759,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 @@ -5781,6 +5771,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..da7764c008 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 at 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 19:05:44 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=1720707592; cv=none; d=zohomail.com; s=zohoarc; b=hkGlvUMVStiPYeCdtCsHejBjLOYjhd4F0L9TX+gDV6of2FMfjspYTUhDHAyEF9mg2VY2LLn1ycr34ThRb3YxsHild2E2RUrq730bep/WDodHLifQKDx71KOlIKBl/IhqW1gDNdCY0DOG/d4zh7to61DmGQi0LlUyEjryi+8WhiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707592; 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=E8FfYVZLhfQmqykNToV7464fETgc8v1WopuhnlmN23k=; b=DOZmZdF4bJVekVMBXtwK+yT2fmFeKvhFwz3/l3tHMuVwPaifd6LD3dNKlIWnrZoWmVK3MSLiIw5WOvO9yXN5WIgWakx6k/4eFh+XeB/OeNsg18SmLy00EleG5y7ABh7ykJpANKm05lvN+clCUpGiiPw8bD2kZAbKnfK5VveozKs= 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 1720707592341283.00833442345913; Thu, 11 Jul 2024 07:19:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRudv-0003pB-5L; Thu, 11 Jul 2024 10:19:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRuds-0003hs-PT; Thu, 11 Jul 2024 10:19:28 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRudr-0005UD-1X; Thu, 11 Jul 2024 10:19:28 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-70af0684c2bso743685b3a.0; Thu, 11 Jul 2024 07:19:26 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707565; x=1721312365; 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=E8FfYVZLhfQmqykNToV7464fETgc8v1WopuhnlmN23k=; b=gzNOIcNZD0Go/3ejyaBzMrwe1/vnoH1imM/TER8RxMlerDqQzSH0ksfZeTsLFijlge epV14ZGFRdekCHAHPdrmOJlA/P/cSRsTBg8kMp6z2164I2vRzgSXzv7QPcXxCkg902FQ 9RUSHm1hOfEJNpwkOoe0ZrySkd9pUJ1AA/TzWuO7d1ZCc3sjGy/y8gsJdXT9+vSUpIyT 4p07hSSFHl+nhgUwTVZTyx/elBREeoFbI27zuE2vq0fxMU8jOX690cWtNodQyfR6svzR H4+ivlNqkznMWsGSvf5I94+Yf3VdgmX20cir18prMb/HqKej3XhV1qatvLBMXBBVwrW1 oeXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707565; x=1721312365; 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=E8FfYVZLhfQmqykNToV7464fETgc8v1WopuhnlmN23k=; b=G48fwlePKN14g37CxfEMXKXsI3q4cexgb2vwoBTvNXlWSaoPY1fbYOkpowSBLZCjvU Mx1IlnjGlazpVvS0SlR5fhmWzFsDkF6TeANvJxzk87vAOeZC6nHQmNN9LF9Imo+AWHEg nab5shjj8dGXTq++8b617ZpXvPsaIGl8+zoAn86wkhmR0glrSy9n0F/lkMmaktxjmFGN UXMb8SOWKdxY+fzyegF8I01xmmVedhYQucKKNS/r31O6Ow9IK/3TW9ED2vTqnVOWaoZJ 4YbH+JIe9XgoCLumr5o6AOp7bl9qwZoS6XoeCyE/j2U3hI99ttZ16nmwNy3c/NRn3ccY NE5g== X-Forwarded-Encrypted: i=1; AJvYcCWPSCNUGcGRaaWZmCeAGXkyssU1hEkS2rx9xNNZ3uIKPbAwvpV1myKyHd8XX42M2HJFBfokx3sgvbix/vYRDxAGj+JK6FM= X-Gm-Message-State: AOJu0Yz4MjITyCbW5+Ho2r/T6USkC5nbNIH90fvHFT1uNMVJwCBRiWg2 MDIOT0x27rhE6AkNGHll2YRnk/ASBDhuSAimsMXQ6SUOhyuDw+Mh7DkkP0ft X-Google-Smtp-Source: AGHT+IEmhuqmMLysUrr4i8UMZ8S/BOJHlLE1G5ubnC9v6rwXi6K4QXnamm6hLHOMQy5ctPrhqO2qJg== X-Received: by 2002:a05:6a21:680d:b0:1c2:8fd1:a47d with SMTP id adf61e73a8af0-1c29820396amr9982671637.6.1720707564671; Thu, 11 Jul 2024 07:19:24 -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 06/18] ppc/pnv: specialise init for powernv8/9/10 machines Date: Fri, 12 Jul 2024 00:18:38 +1000 Message-ID: <20240711141851.406677-7-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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::432; envelope-from=npiggin@gmail.com; helo=mail-pf1-x432.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: 1720707594308116600 Content-Type: text/plain; charset="utf-8" This will allow different settings and checks for different machine types with later changes. Reviewed-by: Harsh Prateek Bora Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- 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 3bcf11984c..4252bcd28d 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..., @@ -2491,6 +2494,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); } @@ -2515,6 +2519,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); @@ -2539,6 +2544,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 19:05:44 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=1720707710; cv=none; d=zohomail.com; s=zohoarc; b=Ad9w+13cpZC3v6cqTTzm3MUxKqEnV8Ep1bMZj+3yGqqEgicgvGPPdXek5+gtA2jHXgFkDCV5hGcI7007c96s54Gm0LnOysmiKWFSgIj62MpKJUA1+5ryVcKwPPgsZu1eG3V24dWOsd9QhffmmZC22VlgPuSTRzemgPimkO68Z5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707710; 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=/lWATjD8bdRE91V0riy/vL3qLlTh4LYdUV5TWY+PHGI=; b=KIS3qU1pEcsPb22W55XPLp7Xf9+YDz0HE6tPtUEd+SKKE57fVLZBak5MfKxZoTxgc0UeXGG1VAPHS1zyCO1zb9op2W0JjR9YpnLn+PgqDHjvzmjqvhhLR5XgYCXzz1YWbncy6IcROXmAcjKCufGTgdf7dn//+mW0tVffxnW0alM= 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 1720707710849607.2258296651787; Thu, 11 Jul 2024 07:21:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRue0-0004GN-90; Thu, 11 Jul 2024 10:19:36 -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 1sRudw-0003yI-TM; Thu, 11 Jul 2024 10:19:33 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRudu-0005VJ-In; Thu, 11 Jul 2024 10:19:32 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-75c3afd7a50so636908a12.2; Thu, 11 Jul 2024 07:19:29 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707568; x=1721312368; 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=/lWATjD8bdRE91V0riy/vL3qLlTh4LYdUV5TWY+PHGI=; b=L5/ozZmuTfWJyIKUfGDA4jzwL68Km90P6gtv88Rb48ctHtMMApd+NGbOiz6TtIZDg0 qOtA+G/oTaMg2UzQ8QNhnIoVhoTLNbaz4CcUVOxLXennvXkBeEz5BEMM+YRiFsTchL8N s86r27d88pSeK4lyYoQ36fC3tS16ZpZmGkaP3Xgrx1RTlVhjtWneynQiW+faue91nKUG w3Zukz+2Vu1eUC3+D9GwezNxtHo7ppVzGm6Ac56SoEAXWu1ljUIys8jCR7bMIzQGLSe9 h68gWCxe+RC6Qv1hmIZ6Qnryh6vF9dv95yo36GzgoXG3RvUK8s5OCmpu7+SozauVpUfN dyBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707568; x=1721312368; 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=/lWATjD8bdRE91V0riy/vL3qLlTh4LYdUV5TWY+PHGI=; b=NYQ9BGmip9rVyDMFOHO79/+e67zSkWvoFtBsVTMbnnzDwsPU0LcVxQQwGak0kCOkII 4GZ4+a/LRWkzZ5AvoGfKio+tzDA8uzNPTtNUR8KCf8JP/eIrvjdNQYCnERe4aBb6KqAl aMfsc92hwuuQugnaCNFCoSEcUCdn6PXtu7vcRt4hgBESOuwnpvKn77aZROOQqqaF/ELb tSw68R3/MXJrRMs0rx5SZbrqMpLZedSvOPZISRDSwDAQGI6PQpSt8oBURSn/TLjfHefJ a+J+C/Q9o5+An1Ciqpeo5RSAVt0uXWo1mdKdfikEoqByzwU7mehZuN76pozX+SfTDCSZ 5gBQ== X-Forwarded-Encrypted: i=1; AJvYcCVDv8NM1bopF7quxfHZhMQ/yUrOFxF26Uhjd0RF5VB/bD3tDX9LOjEej43Wgkm3ZgMHDhVpSff64SI0PmadrCIwJqCqWl4= X-Gm-Message-State: AOJu0YwBeq9Axa/vCvgA2vhuoFb4eSA+8MI4hgt790H6WpMcaHr80LZb C2xkgAqDLoSyHrTiI0iGhSi+p/DtyUIBnQFnrFZ1LtZU7pizPl2f1cPC/07k X-Google-Smtp-Source: AGHT+IF9aAvA5Ita8axGJ3++k96hQI/kNed3G0TBqVnAxHtF9C5dXaMVwPgO6J798zgxry6bAyn6tw== X-Received: by 2002:a05:6a20:9145:b0:1c2:8e96:3343 with SMTP id adf61e73a8af0-1c29820394emr10671547637.10.1720707568512; Thu, 11 Jul 2024 07:19: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 07/18] ppc/pnv: Extend chip_pir class method to TIR as well Date: Fri, 12 Jul 2024 00:18:39 +1000 Message-ID: <20240711141851.406677-8-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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::536; envelope-from=npiggin@gmail.com; helo=mail-pg1-x536.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: 1720707712919116600 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- 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 decfbc0ff7..1fca540eb1 100644 --- a/include/hw/ppc/pnv_chip.h +++ b/include/hw/ppc/pnv_chip.h @@ -152,7 +152,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 4252bcd28d..b593a41f7c 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 19:05:44 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=1720707700; cv=none; d=zohomail.com; s=zohoarc; b=KFrNR4YxfGZdT0wHsKGuoYkdUwcpfFJv81RS9fRcm3pyyWfCOEGr8HDzFf0RBuMMCFpMagc9tD3fcFsYIWJVYO4/v1tAWcbQ2tao6X/Cfsjw/J2n+oZZgXfaj7M3bTmKzMsDp4eUDLYv3eKenDJLfAUNjKHlXaoZwU+bsEEzym8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707700; 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=9IkyAC50oiavRu7uVzyi3eVaZuodeWTVQ2rjbZSzKT0=; b=jGrDm/+8wJZ3hikMoYjzEciSet2XB+85t+6ltC+WN04IKM3XiD8njbsWV0MUXTHMvZyvQUQrEPTUxwQoV/286G7kMFJm2h5WsA24acnvEeEY0TujeinxKQUWwzzL3otOWV+EaDIGN4C569AugdC5EjlZauj4a/vMBdz60MFcKnk= 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 1720707700521699.0934878901047; Thu, 11 Jul 2024 07:21:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRueA-00055u-4K; Thu, 11 Jul 2024 10:19:46 -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 1sRue7-0004u5-Ip; Thu, 11 Jul 2024 10:19:43 -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 1sRue5-0005Vn-QC; Thu, 11 Jul 2024 10:19:43 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-70b3c0a00f2so745397b3a.3; Thu, 11 Jul 2024 07:19:41 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707580; x=1721312380; 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=9IkyAC50oiavRu7uVzyi3eVaZuodeWTVQ2rjbZSzKT0=; b=YbzcKQvlaggZsRo5tRYCCeXpIPysPRHN4nB5ctiSOCW4fIoJRdjngmrATpcDwcsiHm IIki1GBSY/1476uzZJ7yHdKvCJbcg+wiPnoL7hBuY/7PNReGAm6LQFMXTyJosNvGw4Db hfeuDLzT8JyZ0CmM3IOYyfYo1a4KH9/8suKG/BZFub5Wc3aQusqjY6hh+JdlCg3xfX6a WaRYU3brMCRMMn7F83U3o038mQg9Nb7hw6x4gDBGe330UbmdJv/NwcROdRhhnqvsNTU4 VkMyI00lpZ1OrLwBU5ilH9qnAsv84ivG3qzfjr4bVjALMgLdVe9yrmnh7VMxIiFiaAUc 2Rrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707580; x=1721312380; 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=9IkyAC50oiavRu7uVzyi3eVaZuodeWTVQ2rjbZSzKT0=; b=dEyMw0BVPtgN4k/FAc36E9E0VSk/j/IbwIY44ThUcuwJXzvS+ujokhQV/zfxG4z8aw Ew7aEnw42m2385fuuoedXCQQ+E1YJExqyciBT2Pcogx86fpHBsVX0Pi+VoQcz3Psra1W Dn0SdFQ7jsHZb5FWxF2vNwyAdn3s6swyjJD8L/S3R+IloZHmRyisOCdzYu7nuZpNPvcm qwgI1OR3Eku/25Wpl36y3dnNet00p5LtWW47dbwJvLV8UVHt7H2ShZpmA6IaqUovyv31 /ajDrzhzSzZf84ElCUu6H632J5ofKqPjBU1MzYk64A6qb81t683Y4ghw/nhxwClUATN6 P6Ig== X-Forwarded-Encrypted: i=1; AJvYcCXQ9OADekdjPHgwJ6q+VrtOfu3nYRUYJr3rCpKyosi5OKPIQAhHokojKozUkOEyYCRO7Mm0oSM4JzjpJFSahj9hODqohPg= X-Gm-Message-State: AOJu0Yxo2A4acUMimuxyhY4MNZFVEChPn31c7glp63pmxe3Icq6QS3g8 t8ptTb7Fp91/fsrhM74LWQruw+8o72MMmPZCcoxF9XFqh5glKNY+fUyRnfsm X-Google-Smtp-Source: AGHT+IG2DenIyXPgdzjcTXqxLyfgnRvpcrLXgwaSweWn5Ud7CFs836wvu+62OSpzpiLwiuvH0Air2A== X-Received: by 2002:a05:6a20:918c:b0:1c2:8904:14c2 with SMTP id adf61e73a8af0-1c29824364dmr10989446637.37.1720707572137; Thu, 11 Jul 2024 07:19:32 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH 08/18] ppc: Add a core_index to CPUPPCState for SMT vCPUs Date: Fri, 12 Jul 2024 00:18:40 +1000 Message-ID: <20240711141851.406677-9-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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: 1720707700880116600 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- target/ppc/cpu.h | 5 ++++- hw/ppc/pnv_core.c | 2 ++ hw/ppc/spapr_cpu_core.c | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 95ba9e7590..c3a33d2965 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) @@ -1403,7 +1406,7 @@ struct CPUArchState { }; =20 #define _CORE_ID(cs) \ - (POWERPC_CPU(cs)->env.spr_cb[SPR_PIR].default_value & ~(cs->nr_threads= - 1)) + (POWERPC_CPU(cs)->env.core_index) =20 #define THREAD_SIBLING_FOREACH(cs, cs_sibling) \ CPU_FOREACH(cs_sibling) \ 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..d9116c8409 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -302,16 +302,19 @@ 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. */ qdev_prop_set_bit(DEVICE(obj), "start-powered-off", true); + env->core_index =3D cc->core_id; cs->cpu_index =3D cc->core_id + i; if (!spapr_set_vcpu_id(cpu, cs->cpu_index, errp)) { return NULL; --=20 2.45.1 From nobody Sun Nov 24 19:05:44 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=1720707786; cv=none; d=zohomail.com; s=zohoarc; b=W62Oz3cePXf5NQiDbM83aXVi1226LVTytIOYEgbmFsjnvcgf4OUzc6A/AaA+8DkRwle7byEadSmXNQ/UwbbKiurTV03XK5yudE1aJj15IloDMxskJuEDF55PYLVP8iSAyI71SkrtMOfBVyRSvu/46ryqXcBwqvuJ626NTjNTHWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707786; 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=jli+YvhVVSHiuuiIC/ca15I+96k+KsOc4Kts7AF7+34=; b=be+pCbn7kT+De0Pu9DiCQ5D96/5EDuhKSS7PtIqtCrr8sPCtwVJA2Kh4YdUIl1FBOnSFM2j6hlpffA0Brijkus/BrC7KagHiSVRaK6bocjucj8RPri6IGYFjH6u9OmmFgn3Xku2ADQffbqzdpWOPh4/WaoJu2MOiu/cSVZwJZZE= 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 1720707786649335.36672953122854; Thu, 11 Jul 2024 07:23:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRueK-0005ut-2D; Thu, 11 Jul 2024 10:19: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 1sRueH-0005eg-La; Thu, 11 Jul 2024 10:19:53 -0400 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRue2-0005Vh-Mt; Thu, 11 Jul 2024 10:19:53 -0400 Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-80557928673so48878339f.2; Thu, 11 Jul 2024 07:19:37 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707576; x=1721312376; 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=jli+YvhVVSHiuuiIC/ca15I+96k+KsOc4Kts7AF7+34=; b=YgVZB5E8Vy3e5xwSW3l7q2utbiH/vjZG4yY3eryM9mZMzSwMY3BIzkrgbgUTjM95HX 2zTLIYwty7+cSp/Z/4U3ltW6zCbEZC18mSVrVl5EnBLH4NSE2pXXi7N8aw+Gjux1zoOT wSfbJ4qINMrq82nOfGDYHfd9jYhLIoN2XYbXZAI68jvTnRGh2XOpyXnLN/jscpPMDkuG rfAEM10JN8zbe80tRXWE4JgLtl9XgITq6ggxWguUjkPKQV6SlPMiT5Mtpt6cPpA7BSek kWkeXN7qpe1vxWwn04LZU6zKqABQatSkqImf8vvLWNCVpOrvlb+bwCjHokAnwykclnPn e4VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707576; x=1721312376; 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=jli+YvhVVSHiuuiIC/ca15I+96k+KsOc4Kts7AF7+34=; b=L+REQikAjPHW1x5FPHZMYkE4/ZJLejwQff1jkE5cI5ySabk6sumz4ATqKneearFHqL uysGXTh1fZcmUIoA3gqx6+5S9KEbVLjTHNXiS5NF2j4Wn2gPzs8SeHVi5pzxb6Gjn4ij hsfBxRAmnV4azvWhxB2x853h5HP6f/aNe6jqb985lr/6k4yFBCVoGCXwd5KYll9ey92v 4/iaL9aAGCoSWR6x4DH65ycM9vsnHVmHHvWdBWUF9+XS9FleOxDUK+SumW1BILC8icfv ci0VacVMnHhO6pyLJMd65X87E1JmoHQSSyont1ct+rfwI8Qh1KS+tOi5ESvI82GHS+Hk bEoA== X-Forwarded-Encrypted: i=1; AJvYcCVdTBLY8il3VTKB0Edb5y/6oK7WrIzw2UcQLvxgeer0azbtKnts/E/mY/nX7YPQoPZLDMnIggTDxqpYvoKLa9K7DwhI7iI= X-Gm-Message-State: AOJu0Yzd6J9W0X2VI1Ap9Lvi/8Esv/J5hIp6X9hbguc8AFNriC/lQoN7 e59m8zXVYHolmDMXbRckedQChw6PgIuCEdRSFgeWx9eAI2gwpCErCwOPxDPl X-Google-Smtp-Source: AGHT+IHYMzj6s4yAjIs71uou9FNMNnhVgWrhQ/GO+qZVpDdWMR+VAj9Dt7qO6LDfSUCPnFoPvjf6rA== X-Received: by 2002:a6b:6b16:0:b0:7f6:8303:ba80 with SMTP id ca18e2360f4ac-8000192cfc4mr905616439f.11.1720707576228; Thu, 11 Jul 2024 07:19:36 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH 09/18] target/ppc: Add helpers to check for SMT sibling threads Date: Fri, 12 Jul 2024 00:18:41 +1000 Message-ID: <20240711141851.406677-10-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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::d2d; envelope-from=npiggin@gmail.com; helo=mail-io1-xd2d.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_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1720707787306116600 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 Tested-by: C=C3=A9dric Le Goater --- 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 c3a33d2965..a74b753c99 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1514,6 +1514,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 ae483e20c4..9349001b76 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6975,7 +6975,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 c0120c8a88..f33fc36db2 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -3005,18 +3005,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 @@ -3071,7 +3064,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 da7764c008..2032f3f7c1 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 19:05:44 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=1720707713; cv=none; d=zohomail.com; s=zohoarc; b=ORvgdjB8rnCoue/lE81IP3rA24Nmtc5ggyM4AvhRmU8O4Qgnp1sDB723G73RKQRFRrnCXXX2kbGgsnPJJmU7eF/an6ESuOZ2Esbi47H4utDb37XeGG4sD8+L6MhtfI7Jv+NzMgtx5cgFWI7aTToVkMpENUdoeXNsQBGEWzdiwTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707713; 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=eMWYF7RruolDDN7w8ZRjDbzY0WoBV0w417XKF0FNT/A=; b=O4osBe9ypJ8YNxn4frAojlUCbQ/2fvWCQPYGJvT2G29uVEq97ChURiLzTGZQ+P+kA4U6AFStE/Nq4IJMERQqO5bwFNbbWjll8ZYjTP2C92CpC7jgydMxUiBUmiixquDCUV2Uhb5Jd7vx5qEogrFjrgxf47style8nU0TMghEcMI= 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 1720707713828936.3891695497892; Thu, 11 Jul 2024 07:21:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRueC-0005GP-KY; Thu, 11 Jul 2024 10:19: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 1sRue9-00055P-VB; Thu, 11 Jul 2024 10:19:45 -0400 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRue6-0005W0-Dn; Thu, 11 Jul 2024 10:19:45 -0400 Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-8076ef91d8eso32562239f.1; Thu, 11 Jul 2024 07:19:41 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707580; x=1721312380; 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=eMWYF7RruolDDN7w8ZRjDbzY0WoBV0w417XKF0FNT/A=; b=DnC2ONPOx/shVbFvuhn5eT0Pv6waJVEyYgZBRUoQDEzmWrx/iSfeDmnjhDkv6SJiMy hFJY3d6Ou3f5InUin94cww3u0CTJvISYw8y16Euio81A/3yuh6n4sKOn0GCFATXk4BWV XcG22OP47JnxQ7IikmzQiXhKVj0JKFhGUklyNsowjWSfd9XUEQqScgDQxNUCo7kt2+j4 mx2I9SdWe57cKSdeXzXABcvxW5YZ9BDOMd/DpmzuMLySF3QHT/vWZmaOoraFRQzF/zRu 6TaZyBVId66gogmyHGqEX+VQHOxEHT87LolTlGCC8PVC6ifv/4RWojlOaKDBzcNnu+gk ifGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707580; x=1721312380; 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=eMWYF7RruolDDN7w8ZRjDbzY0WoBV0w417XKF0FNT/A=; b=mO1wuqiwvXD1nNFEuJ5pXM9Tu4RAS8x3HD+ZLdU4kFb+W1x5OOX3obhdWtT/sssU1F J4l4nuWlJ9XwvqT4fakxXetztfOiB1dLarrqi4xFlZfzUBOweqFx/BRfEuw6ZD4nYoWD JF9EDu6xIfhyFG13gVro4l4IPF13LQqbAvBjBdpAbwfYxcip036V2ebZJ8BWTv+H3a8q WM40WE4R4RNGo4f48HqTW/1nmuxJ5jczcgmzmnnyBJPOg4gcln0TfTT9sglei3bJL1TW 7taZt7FzlKGTkabwE05pTU+GVT/hB15A7W8SfpaKUkbJar5wzT9RsyuRUPFRZ5snS74U yg5g== X-Forwarded-Encrypted: i=1; AJvYcCXxxkFm35gpFmwMO8Z5uCV0YhAu0wGmrhElbDS2h2ifQcrlEHieBtyKgeBq5lVGhAc1uKrHjV7Y3umn+IrkLzUD18e4ir8= X-Gm-Message-State: AOJu0Yz8P7NbOTu42y8QheZOG656z1Usjy8G7H9gS5+5teuRvofb+J7E RhZnDD5BAe5KKEH13UK7yRd/e/4fjgLAI3JdQax4NBi2JkHB4QoaJvEVPuR1 X-Google-Smtp-Source: AGHT+IESAXZTt677gB144RNQl1ClKjpHLLs97r/Fp/cOWe4bmQZMau0atfHTTTrXd4LW8gR6FnPz8Q== X-Received: by 2002:a5e:9706:0:b0:7f6:82b2:909e with SMTP id ca18e2360f4ac-8000000c52bmr882845839f.2.1720707580121; Thu, 11 Jul 2024 07:19:40 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Harsh Prateek Bora , qemu-devel@nongnu.org Subject: [PATCH 10/18] ppc: Add has_smt_siblings property to CPUPPCState Date: Fri, 12 Jul 2024 00:18:42 +1000 Message-ID: <20240711141851.406677-11-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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::d36; envelope-from=npiggin@gmail.com; helo=mail-io1-xd36.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: 1720707714928116600 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- target/ppc/cpu.h | 3 ++- hw/ppc/pnv_core.c | 3 +++ hw/ppc/spapr_cpu_core.c | 15 +++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index a74b753c99..35a1cb65cb 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) @@ -1516,7 +1517,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 d9116c8409..2c6eeb41a4 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -314,12 +314,13 @@ static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc= , int i, Error **errp) * and the rest are explicitly started up by the guest using an RTAS c= all. */ qdev_prop_set_bit(DEVICE(obj), "start-powered-off", true); - env->core_index =3D cc->core_id; cs->cpu_index =3D cc->core_id + i; if (!spapr_set_vcpu_id(cpu, cs->cpu_index, 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); @@ -350,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 19:05:44 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=1720707764; cv=none; d=zohomail.com; s=zohoarc; b=JtzoEOIKySACjiikPe3Q8doCWKZn8GdcMTBpT6ZkITwasumhVk3dJoSU3Rhyke1Q4h+YwNihaLVdwYUpk+BDsehS31K4M6DXpZF6i3pn7TSJB3EvFGAknC/WEWNcmljv0aHtHTqpSpXSHs+/yLX496jTDwnTZ5TAwKfKDBM6JKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707764; 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=HvkgUoe55ZrWbdSf3vk0rD7Fyim0e+VPTeNFk/b/LZk=; b=VDNIj5FEfqHmzmDOFOmQHXiNlyqA/GkNvqzH9whMN24rpVh2zWp3sRYrf/MaQ22Dip6V9/QVepxZsC92teK0PgggcEY5BOWrACitWeVbZRhzgeTRWgPLohGGEGGTlE97iYXUA41zgLEuYcz95UlQ2v05xob8XWKHW59M1w/pc/U= 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 172070776465048.04907262785866; Thu, 11 Jul 2024 07:22:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRueE-0005O0-9r; Thu, 11 Jul 2024 10:19: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 1sRueB-0005Ct-NY; Thu, 11 Jul 2024 10:19:47 -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 1sRue9-0005WM-Ru; Thu, 11 Jul 2024 10:19:47 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-70af5fbf0d5so667897b3a.1; Thu, 11 Jul 2024 07:19:45 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707584; x=1721312384; 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=HvkgUoe55ZrWbdSf3vk0rD7Fyim0e+VPTeNFk/b/LZk=; b=kZ/j0BgFHeccUo1OaVxmXXjXcRPRXvxY6P6s+7truPG9I0xcYX4DCtCwfb0p0Fy91N nUD1WS+zc3/Lw9NO7FaQw5LM+LzNyjTxQcj8Umud8wqril67TQ6KKYIICmRS/tz9d11A xxk9eGP773/WFLQQhqeLePZYjLaanev9syCjm4Ku8uzh5EYWc5MieuKhYpXSeG96Rv6h DS8tNjrs+/W4dY+fF7nrHmn+nznDYe836BbrDSKXBWkzofNTWZ/5KWYEYhaBOgBiJAZ9 RMf6GfzZg+tNaMKLxoqCvT4YSoXfwnbZirwsFicS9gW9eqW4StibqgYYlFLF6qmUOMED vXmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707584; x=1721312384; 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=HvkgUoe55ZrWbdSf3vk0rD7Fyim0e+VPTeNFk/b/LZk=; b=UncRgrUf5lN0ZLpHT8qH0dhskv6eXdUByvk1CBDqUee4rM/lLHM1RalYUjwoq+e9vo AjKarc0cueuhaXqyQZH9gf8d7HI9ycBnUmhdSli7g9wb7bYsHBmJypoMyw2U/qEsrEfM K3SF7HtKBB/AIvep7cQTXHK2bRAWpYigb2jIirBcoNL43NbSjh6p/fZ3t1oAnh93fQ7d ZE3PR3qLTaZt8KTbT8U3mVrop81gt8KKE7LppAbBvMMDdh6QfAAKculMorOR0DD5chLa HL4SCKytFw+U9TIDhgpbzycbYXBHxIfopc7EfCqIYP/P4WwLOJP5cWYtr3RRZm9a4S7X jUVA== X-Forwarded-Encrypted: i=1; AJvYcCVFFebjfK5saQCj50E4Q1xA/YjYZIare6Kh+gVzJnZ2JpTgcmO5PBDWT9ic1wForeJgdnY1NQvajbY6JuNDI/QKQSp6C8U= X-Gm-Message-State: AOJu0YxOWK4DTUQQcImf09lbk7QBZC+9jG5RKbLAbI/KoBiNBcmJ38vX /3r5yoWGKzRFEf9SOpOOOPz8zLtS84FI3KQf4oyEMQRQObrJfhO5SGwpAgzl X-Google-Smtp-Source: AGHT+IHGxOyey2MidNkxnErralrZ7WpXZKPN5faA2/LuHP4UbzVFnTXZ6IsQHvJ7/lASQkqfd89MCQ== X-Received: by 2002:a05:6a00:194e:b0:6f6:76c8:122c with SMTP id d2e1a72fcca58-70b61dcb17emr2209223b3a.16.1720707583649; Thu, 11 Jul 2024 07:19:43 -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 11/18] ppc/pnv: Add a big-core mode that joins two regular cores Date: Fri, 12 Jul 2024 00:18:43 +1000 Message-ID: <20240711141851.406677-12-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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: 1720707765224116600 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 Tested-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv.h | 2 + include/hw/ppc/pnv_core.h | 1 + hw/ppc/pnv.c | 79 ++++++++++++++++++++++++++++++++------- hw/ppc/pnv_core.c | 7 +++- 4 files changed, 75 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_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 b593a41f7c..d2ddc49142 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,19 @@ 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 { + PnvMachineState *pnv =3D PNV_MACHINE(chip->pnv_machine); + + if (pnv->big_core) { + /* Big-core interleaves thread ID between small-cores */ + thread_id <<=3D 1; + thread_id |=3D core_id & 1; + core_id >>=3D 1; + + if (pir) { + *pir =3D (chip->chip_id << 8) | (core_id << 3) | thread_id; + } + } else { + if (pir) { *pir =3D (chip->chip_id << 8) | (core_id << 2) | thread_id; } } @@ -1203,11 +1236,19 @@ 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 { + PnvMachineState *pnv =3D PNV_MACHINE(chip->pnv_machine); + + if (pnv->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 +2221,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 +2243,17 @@ static void pnv_chip_core_sanitize(PnvChip *chip, Er= ror **errp) } chip->cores_mask &=3D pcc->cores_mask; =20 + /* Ensure small-cores a paired up in big-core mode */ + if (pnv->big_core) { + uint64_t even_cores =3D chip->cores_mask & 0x5555555555555555ULL; + uint64_t odd_cores =3D chip->cores_mask & 0xaaaaaaaaaaaaaaaaULL; + + if (even_cores ^ (odd_cores >> 1)) { + error_setg(errp, "warning: unpaired cores in big-core mode !"); + return; + } + } + /* now that we have a sane layout, let check the number of cores */ cores_max =3D ctpop64(chip->cores_mask); if (chip->nr_cores > cores_max) { @@ -2224,7 +2277,7 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) } =20 /* Cores */ - pnv_chip_core_sanitize(chip, &error); + pnv_chip_core_sanitize(pnv, chip, &error); if (error) { error_propagate(errp, error); return; 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 19:05:44 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=1720707796; cv=none; d=zohomail.com; s=zohoarc; b=VDKGwaUKaRh5Eq+3ibbaq89fFvp4Fnw371s6sSnCoLt53Qi5iLX335gXW8LVWP7UvTY4dqbRornG+8nsCNH6apJW5xcM2vGe16wYOc8NaVmdLN6xf7SWVgkICpZsuXW823mtM/cT9AQOL1A/nLKLqXTRAHHzV2uRFf+3eP/I9kA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707796; 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=98h1jtA/ysXVkdo2AXd2AHkw4hRmAuxtfKheKSDQWJU=; b=jIN04KlQ2bg0aAJscItl4PwygpB2hylyZ0L4MJiyCGFsKhuAFUKb3FruUgQNz7+gJ7/AJN4GmEON95F3TBrAozEcIHzV5Z8UtiJzf2rcyPgBUHADNug+HA83831+BDP1L24f9J3SAyHVmBxGnWNWi/E9OYwguH+TRH3I2t8NzRE= 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 1720707796723855.8253503676202; Thu, 11 Jul 2024 07:23:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRueI-0005oI-TW; Thu, 11 Jul 2024 10:19: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 1sRueG-0005Wg-0O; Thu, 11 Jul 2024 10:19:52 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRueE-0005Wv-9X; Thu, 11 Jul 2024 10:19:51 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-6bce380eb9bso585795a12.0; Thu, 11 Jul 2024 07:19:48 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707587; x=1721312387; 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=98h1jtA/ysXVkdo2AXd2AHkw4hRmAuxtfKheKSDQWJU=; b=PsAD/u+ZlOykdiwiw3Ok58aV3PyYqf4/MeqHxUQoRowilSl9wfvMKuyxYjXGInIl+o DUmmeWaL2p+1QO1TeN1hMMCp3HBn36N1GHTh1QNgIdx/WXaCsnqbK1K+WzTIOGAPvgwz XhAoCIc9ApqLHfJIgdOo7SP3GER4sp1Kgob0i3Zs7EOGQcumPBhbe27lIVGVCezkPD2h PBUY81KK01xHeIMqzJjKUeEO4oqJifbc0p8cd3/Pnfv0Zl8VEQcdjFVsiGrLBetz+Pbw PY0jBIWIngRvMt6Ya0OzcLkJdNOO4puzqZN59Ly8AF4wwI7OyYtLES9FlkPTkbKUSST6 V/JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707587; x=1721312387; 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=98h1jtA/ysXVkdo2AXd2AHkw4hRmAuxtfKheKSDQWJU=; b=POVYkpCRzaYC7eW3lOjBakXNO6gz9UzmwLT/JSF5QJGYYFDvmCEiT/8nfsjeJTpFdj El0GJylsWEsDOO/qeWYIH+E/52+7eBtFzwLc1cW85GUjg8ZGDdklbSv/YFn5t5dmv2xG T2IOSsLHxLig08iBDXt0/UJKenQ5009mSi7M96bAJY3oBVWcRvl9p93uCn4bzKm2fJLf 2V25f5Ys824SL7eY5GI9t1tt1NRZILE44pp3+vkIG0CUMQsTl8rtjhJgqhmPTs0Di3Tj inQi33m6QdeVeiwwZ+NaUV+RRD/FR+ni73iFiw+PuucdQe9CJNxC8t6F2yb7GlAXoVTq i/Wg== X-Forwarded-Encrypted: i=1; AJvYcCW+Irrlku56L0dtlgYWHN3rYpMGlWjbQTkRgVmDUtCSaFt34Mq6H7WGdX0FwXYtokoGlBbC5CMf0lu2GEFoCm23IGRsiJI= X-Gm-Message-State: AOJu0YwpYgDoeeT7uw9XzLQHF9p0/X5+YnRl3y0TWTYuFC0KKMTQQbFX RB6QV4XUZwPFankO8mQGkY0zz6fdtXohZi/P6S/eGe8/rd4gJXM7RGq5Ahgh X-Google-Smtp-Source: AGHT+IEdnUkIvLN0fF9Y0IsgMwN8Pr3QYgKA3NygzSsqOZLoOuiKyrsEN6Gnn5pk8lacuQm0T81k5Q== X-Received: by 2002:a05:6a21:999d:b0:1c2:a0b2:e69 with SMTP id adf61e73a8af0-1c2a0b2110bmr8248049637.33.1720707587228; Thu, 11 Jul 2024 07:19:47 -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 12/18] ppc/pnv: Add allow for big-core differences in DT generation Date: Fri, 12 Jul 2024 00:18:44 +1000 Message-ID: <20240711141851.406677-13-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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::52a; envelope-from=npiggin@gmail.com; helo=mail-pg1-x52a.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: 1720707797250116600 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 Tested-by: C=C3=A9dric Le Goater --- hw/ppc/pnv.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index d2ddc49142..d7488be74c 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 19:05:44 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=1720707694; cv=none; d=zohomail.com; s=zohoarc; b=RD1Jx78mBRTqcfWDddLHSRZgPGXBg/u5sQuOPhsxPlId8uNoMjmnRg/G8ksYjxkmxuLAOYHEEWcKhRqm5oGcylNQ5mKMLpQfZWVN96EHv6n8JTPiRs0T+l6uDU+qCJJLhOsK/V8QNcbckiPZziBU5cDMqXVwzYR/nfpDozd4DnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707694; 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=STxt8Vj/U1SWpZfOFyNBjoARv+Ee3d29/WAKBVLHbn71y7pESsVSavOw8PZFy17EZaaU2miUhqSbvM7uat3/5BXu8lYVe08turr/aKRfv0cEFjYipHNxZ+s+jRgY51jBYx4yB3wsPJP1D5cnvI6tvgN/9rErgt7jYQ1CYZ27sRo= 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 1720707694369487.1430067517407; Thu, 11 Jul 2024 07:21:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRueL-00063h-MR; Thu, 11 Jul 2024 10:19:57 -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 1sRueJ-0005q6-1m; Thu, 11 Jul 2024 10:19:55 -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 1sRueH-0005XJ-Dx; Thu, 11 Jul 2024 10:19:54 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-70b0e9ee7bcso763892b3a.1; Thu, 11 Jul 2024 07:19:52 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707591; x=1721312391; 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=H5ga13oiWb7etQmAi1sWxD31LI9FRLCCQBk5C7gdQnqVLjQXQ/L4+asy0ebTlI/MY6 UvcIWFKkoyq6kgEEZEES0X5Kpq+e3MyWmMYfADgoolkix5yv/UjUnTFYrc4BT0A2Zid3 0ILU2cL8R3BIHSeYAV9F2kW2kNBoIcs4JgQsKY7318vIsgkFuW7AwtqKa396iMvaOTlE wPWVkc5kipDRv6XZxwufdQm10Cim8g1mrCS2rPfXXGHIuWBiX4I0Ysuod6mgsThRdVw4 aTFYEDQfeOAXXRVn61HlpFtPEzgJk2OOSUjqNcDSjNNZGerOX/kJe8lCDyIhjicllHc+ A+Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707591; x=1721312391; 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=mVSJp3nuu6/Au4BtrFPQKNElzgBSLP1BZzeFqH3GlX7dVPLyc7ZQS5dtG8ffeb5mBd 56DbKWtrOtjJZQBcc/azF6gtZmBOJdRIlbskq/xzG2SDvxLoKMnZxUVh+pQj0uPkdcGA xDbqXCvXKVyW+rEtAc7OIyJHMmhTSDakJ8yplCClKOBskTPbknvWB9+cR0L++RIqQOK1 V5AJDOIYBRSDGnPMzFZjesGJmcuG5kMCTcYIRpgy3YRPIX77aUk66tpKgXfpyq8BTtUj T8uHlOZVyl13WqzXsA2HTny6L1CvKx3Js+owi7dqB4gIGkoCtLskV8TRSFB954XYco8E syHA== X-Forwarded-Encrypted: i=1; AJvYcCW6DOF3/I8kQjiDptMDaxEUlV+4l01L1AvD3iHKEup18l8eYAMm0hN3S79JNdUA26XFidlW+b/6hw/KNSgvCMLYychVLpE= X-Gm-Message-State: AOJu0YxElxEncDpkxwqwJiaF/IQl41rqYQZUwRv/+K/5178gmOsC4Mq6 HG+apgj+0WXOlfF3Q8WkNUYoJU8HC0GEhZfkkmyLLr1/EfogTnrHJ1Se4Pbk X-Google-Smtp-Source: AGHT+IFcZDiKX7ZkEQm0n56h3PAVTORrpPKRnD6I/PBtT7rrLUfJyGtnDGnZkCUjqldQ7TSgvEa2Jg== X-Received: by 2002:a05:6a20:4c82:b0:1be:c414:7ae4 with SMTP id adf61e73a8af0-1c2984d7a62mr7401014637.60.1720707590816; Thu, 11 Jul 2024 07:19:50 -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 13/18] ppc/pnv: Implement big-core PVR for Power9/10 Date: Fri, 12 Jul 2024 00:18:45 +1000 Message-ID: <20240711141851.406677-14-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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: 1720707695073116600 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 Tested-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 19:05:44 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=1720707679; cv=none; d=zohomail.com; s=zohoarc; b=NcTdSISgGro7QewNVtd+p6Z9S3cyEGAk7iPhZDULEysmx8PiJ8Eo3vx6VpmwjmRuXT1PszsD+MO35AyDhxewUJjf5V2h/G5nsIoabv9iPFWYlYL9gczPA5fgSGTguOJlfojJwq369N5kT5Fzjx2Jfb67cQzPUxScKZaY4C0qqIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707679; 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=B8fUUkofZlD0VQNVjPS4pmLNGcMZ/HOLexvY/fa0/IU=; b=hRdQtLtkr0W6KsDBVKzzI8YvenKdOGOvR1sQIF/h1QIGb/nNAgHtt5wH42Fie6jSH0VAT8F1IZwl31o/VMko5dhGtqtidcLVzIFqgoM1C+XkchNsAImhfyQxTzjRn3SXWu1UM/ToEUY/5wg34Z4t9GhwRJ+Vi6pgt6LRQ3e4mak= 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 17207076794971022.6894797909524; Thu, 11 Jul 2024 07:21:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRueP-0006Tf-8c; Thu, 11 Jul 2024 10:20:01 -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 1sRueM-000677-4t; Thu, 11 Jul 2024 10:19:58 -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 1sRueK-0005Xo-I2; Thu, 11 Jul 2024 10:19:57 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-70b31272a04so1355853b3a.1; Thu, 11 Jul 2024 07:19:55 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707594; x=1721312394; 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=B8fUUkofZlD0VQNVjPS4pmLNGcMZ/HOLexvY/fa0/IU=; b=LKmTmznksy72O/hiFVf/lqIqR7eh7fQMqMKyun5wTz/g5jo/xyesooi1olos6I59qF O6Qm/6bGxM4l8e9rCO5swCIGWdKt1TtdTRrqj+AQyomqcTMba0+lRaZleSAeDFsQL0En 1GoQzdjyobT1BKZDadmSJb6D4ZgQ4GPAvuT4307RvndCBvxkd6rAWPTDiQuNRAo1gX7M 8Fsi68toGT2KzqLttNnVEpy7PovQcoXffhSMj3rcJjv6DEKVotcVr7+CbKslWil4Olfv Q9dKjNxOYE++AZUXWB7uufjGf1Vw3cfuqzQe9m0zoFvMcmlkmFCiLNsugG6PH8UJs3du C26w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707594; x=1721312394; 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=B8fUUkofZlD0VQNVjPS4pmLNGcMZ/HOLexvY/fa0/IU=; b=DNLpPiXbpE+Ea7kz6xU80mNG46LWuWWKZbDmCH9Y+1Ey7uW1JxTC1tXEENNvna9G4u OI5e7EPMRvCD/b7Tzr14q3mqdK2ECeSChGMTn4uPlCzZXZf86VaNOqMjIjOjA3HihP5C oHVSMUpkQVtOnCWhc3LsJ+02z5x/HCszXNEBryDeWE5BF0d7hALFAwIRsUte6nop152N 77gNSyTy8UH+16JOc6eLdXfHXGfegD1moVqwxYxVd8uDjEyQW6lSg2WA+NSwv5zkZKQ9 DLAHRt0pq8xvfpRRfs4wyxmkwb8OL3ea67vLY08Da0AZYLEdUyPq5317CtxIa41GGMjp 7iRA== X-Forwarded-Encrypted: i=1; AJvYcCX0KqfS19KEwXreni7uic9fLEgh2OWY/aOA0LQ8d4swSOCVjm0QqxtSWD2+lQQWYwZIyKqenEBIVKrWGY9A7/zdnVRzrQI= X-Gm-Message-State: AOJu0YwHZNJY62VQ/CfM2HLt6Ho9o3u9kyjqJLA2Vhcl+dZ5CxsR9H6P sLa7+fGDxv1sf9oPFE3B5qLHZNvfHd5XNsX8iaROra9KYztwcReBkbqSd9aJ X-Google-Smtp-Source: AGHT+IFE483TGpRXNwj0rVPfaqgNEyV6O36xfDI/oU/2vV31yYGOP8wkvz0bhyxyTl+WtWP3mav8lA== X-Received: by 2002:a05:6a20:72a1:b0:1c0:e619:bdb2 with SMTP id adf61e73a8af0-1c3b78070b9mr2814309637.14.1720707594443; Thu, 11 Jul 2024 07:19: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 Subject: [PATCH 14/18] ppc/pnv: Implement Power9 CPU core thread state indirect register Date: Fri, 12 Jul 2024 00:18:46 +1000 Message-ID: <20240711141851.406677-15-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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: 1720707680734116600 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 Tested-by: C=C3=A9dric Le Goater --- target/ppc/misc_helper.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index 2032f3f7c1..aa255233b4 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 19:05:44 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=1720707781; cv=none; d=zohomail.com; s=zohoarc; b=OAj5FTx5fKzsK0Szch73m9yrnc7RIxD+KQl4xHrT6BjztLxBpe8SM2kh8alR2JrlhQDYwKjJlWecOx7eXVyIpXuC5FbaJQA+ha3CYcRFoom/DG2B8zHp6Q3BEvPrZ5EuMUDxqbgRAASwSJ1WN15dRftMN6B1b1NSrJSLbEWhLjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707781; 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=mInheJXYc07E9z2x5XuVHPcAsdtfO6FP7woHZ3/CMp8=; b=IBhu95+LQWli9E+luwqifTDb/S4dGb2gnD57MkbHRMDEPYvXPOrQvj0ARO7a7H38MDdm98j/Tl6GX1QYXYve0sqFRzjyhasOTElYIz2QVzeAl5gR9njD8hORfKQSDUPcKrT9jByNSrRi1Mi2Rhvhz9iW/fd3nNVcloY6pUVG2FE= 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 1720707781516177.59451554248767; Thu, 11 Jul 2024 07:23:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRueT-000726-Rt; Thu, 11 Jul 2024 10:20:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRueQ-0006b0-Dc; Thu, 11 Jul 2024 10:20:02 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRueO-0005YS-95; Thu, 11 Jul 2024 10:20:01 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-70af8128081so779066b3a.1; Thu, 11 Jul 2024 07:19:59 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707598; x=1721312398; 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=mInheJXYc07E9z2x5XuVHPcAsdtfO6FP7woHZ3/CMp8=; b=E3jlz8ncUgNJugRtyXsLIke0mjWqF3mX0guFT7DrFjqUOvWbl/0Wg32b11YV/ysb5A unFgzXVRVeCJGmG6NZAwAOCMCisGOeq+q49oiUXqdF8DvOoaryzUtxK9kYqPoWtCUPsg FyQhI/NyDcE1OS3FlhS6C2JPmd4w8/753wVjmyTurOw4/tZvdqtQk3xCrPfmRDwzERDg LyXDU1HC5cDTLwE5Lxpyf6f62ds4BOAbicM2MXWK/eCm/up3JJYJXvpRsoOuvr+sA+jU q0qM6oYj4wv6MJmjlcSJPMRAm1rxFQcFhwxxiyeZ218A3QH9D/k2XPWT0DVdCHv4cbvD QZxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707598; x=1721312398; 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=mInheJXYc07E9z2x5XuVHPcAsdtfO6FP7woHZ3/CMp8=; b=V1Y3+Ufs0aVT/XucoJ/Ls8QwyyXn5woq4TeHdW5pUJiRLDN5Yi5EonIx2PLrYDFc1w g86lwqpPx53LPpatDOfvq5VL593OKU3Vr+OYbwU/Si7mYaIDhfwbvkM3mXRfg91GSEhJ 89Zz4FE9irwrKl80otb7iuTCBdUflyTrEspbfqnBbUd4iTlrWsJxB4O5f00Z0wIUwSL3 BYjuenOwm+k9650+752REh+Yy6n0i8CZPeM38ZCoI0Rq0va37O8aI8wb35fsWITbpkDf C8KFpB/23bHPB5LwQ4PLvy9rhVJCt2+6GKpFGoLUZILeMKCyaRm0IXOomm2HLBIhsI7D ENbw== X-Forwarded-Encrypted: i=1; AJvYcCW0Gl298mNm8XPBzM1infticYlPMR+3TNiJoAIbbKJX5Q/g5ySbmshNTiueUrJB8FqXy9KGOcPO89cUYhsutU4cyOGGgiU= X-Gm-Message-State: AOJu0Ywe6i36AQM1F/OxcMVjR+sK2ppx3VDljZlatRVnjdYkNuwIu4az HnrnQRBlqYT8G2nD/2jrSVsRZ8jQ7uD5eulmJvPQ+obU/zX6G+mnZ24pnz4R X-Google-Smtp-Source: AGHT+IFQhpMqyUl08TBByaZvJzRsvz96DxutP7BJHGr3nfd+PSJ9H56QH/NjRXWfhZrkzCOrMSjT4w== X-Received: by 2002:a05:6a21:6d87:b0:1bd:2cea:f6ee with SMTP id adf61e73a8af0-1c29824d499mr9574236637.27.1720707598022; Thu, 11 Jul 2024 07:19: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 15/18] ppc/pnv: Add POWER10 ChipTOD quirk for big-core Date: Fri, 12 Jul 2024 00:18:47 +1000 Message-ID: <20240711141851.406677-16-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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::433; envelope-from=npiggin@gmail.com; helo=mail-pf1-x433.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: 1720707783179116600 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 Tested-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv.h | 1 + include/hw/ppc/pnv_core.h | 7 +++++++ hw/ppc/pnv.c | 1 + hw/ppc/pnv_core.c | 3 +++ target/ppc/timebase_helper.c | 9 +++++++++ 5 files changed, 21 insertions(+) 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 d7488be74c..efc9cf2cc3 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2650,6 +2650,7 @@ static void pnv_machine_p10_common_class_init(ObjectC= lass *oc, void *data) pmc->compat =3D compat; pmc->compat_size =3D sizeof(compat); pmc->max_smt_threads =3D 4; + pmc->quirk_tb_big_core =3D true; pmc->dt_power_mgt =3D pnv_dt_power_mgt; =20 xfc->match_nvt =3D pnv10_xive_match_nvt; diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index a96ec4e2b9..68cc5914c6 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -280,6 +280,7 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) PnvCore *pc =3D PNV_CORE(OBJECT(dev)); PnvCoreClass *pcc =3D PNV_CORE_GET_CLASS(pc); CPUCore *cc =3D CPU_CORE(OBJECT(dev)); + PnvMachineClass *pmc =3D PNV_MACHINE_GET_CLASS(pc->chip->pnv_machine); const char *typename =3D pnv_core_cpu_typename(pc); Error *local_err =3D NULL; void *obj; @@ -288,6 +289,8 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) =20 assert(pc->chip); =20 + pc->tod_state.big_core_quirk =3D pmc->quirk_tb_big_core; + pc->threads =3D g_new(PowerPCCPU *, cc->nr_threads); for (i =3D 0; i < cc->nr_threads; i++) { PowerPCCPU *cpu; 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 19:05:44 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=1720707626; cv=none; d=zohomail.com; s=zohoarc; b=V/Lg4BksH+Xmh77aXFUuyJrlnkWxOvIIhfdM+GkTTVmR/OdLIt9ZJJfnOpU4HTQ5JJhFqzfmJV7uHbMK8WpJ1n+b5/EpbJQq/XQuT2aySFGhfSZsLmbzFohzv+75QroyC7ZX+goXIU3Ih6yx+jRECoKuPlYg1HLZCxOdYGB3GZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707626; 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=XAo6xjY7Z7H7lkRVE4dfescS0XtE27pY+OFTM0PcwTU=; b=U8qNKQVdAzX/4COXZI3dCl4uf8BTcgppxy7OHtG/Qw8DHV/EcSSDI0f/3jh08o2cqAL+CXJm9MtzWQ0uqwP2n/z9woMlG7QogtNsnTixu9fwkmQEJnrjRMFd/3AsnMywlcxTydJVMIyq8bD0YuzubAajtJqmzNVOZF3Jf4trbSc= 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 1720707626689439.77011653457635; Thu, 11 Jul 2024 07:20:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRueg-0007wP-6l; Thu, 11 Jul 2024 10:20: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 1sRueV-0007Fr-7g; Thu, 11 Jul 2024 10:20:07 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRueS-0005Zg-6D; Thu, 11 Jul 2024 10:20:06 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-706524adf91so821932b3a.2; Thu, 11 Jul 2024 07:20:03 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.19.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707602; x=1721312402; 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=XAo6xjY7Z7H7lkRVE4dfescS0XtE27pY+OFTM0PcwTU=; b=MAxXNraym6WhSrZ4zifBrOPJ5GkyWCU1nMDZq0njqVcbT1dlXq6+VKJliUMFBrqqIr H9CPMW+GXRMaZNe4i5IHmGPGRWMrEn/EjimM9NQjMcUhrRze7O4idgs7GEVSuGo6pXX7 Se9X6P0WL+PGVyWr78394k7cDGdvgkrS9X1P7ibBJlbUH617SsCe9kpIQWyJPTNEwU/+ pSaaiMT294HFzpwUcoH4VXmhH9gDgsGgDUUGdqKaYhSzMBxLMCyGoaYd15uCqHA5IJIM 7s3w3VTiThZgp+zwQYqb6AZlokSF4aVHp7qvbZ7nDZzcCet9rOwHZ3uwHP0BeLorqDxs y4Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707602; x=1721312402; 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=XAo6xjY7Z7H7lkRVE4dfescS0XtE27pY+OFTM0PcwTU=; b=e2U+GMb+LAwqiuCv/1l9XD8yUstxpU65YuQNfGc6gBhng47gmN9JPanL0JQzpzO7sA 223G6CYKY2u1p8jnedj2asSpbHEIQdkG02yjviNXqzTFGim762K8eJhV+LsAlZOyo2ui fPOt6UvwJsiNl8YpIetc4k+v778FS7SrXO/rePaPzgP0tQPtM6fZtapCIcQzmzjeYsc+ BQFk7XwZw+LacpEgio/J5vzD305Hj4jANB9Cjv/NwL4XTOTZbaPagzUns+8odyP0tTEh yolxpRo6JWlSj1F6OtiMoVJxDzHTsGQeyibLviP8OKN+WlC0hJRNg03A/n5Lldg6TFmu 1pQw== X-Forwarded-Encrypted: i=1; AJvYcCVSgaMthBaQM1Oacf/grsFYOT48oaUF1EoIt3yCYuePzzsF1uwDKVVe9j7/o4tPAqM6oFI5/aw6XEv0vHTQKPziFtU9vxY= X-Gm-Message-State: AOJu0YwTfX2BCWmoqg8qx1Lg+32odTdP9Y+WcEOsNQy3SA2fPkf740BY SfGK5b68DGb0aOW8uOGu0fJ4DlW+9tk8emqhlFB2/gFF5QxtNHZSOZtXdLaw X-Google-Smtp-Source: AGHT+IHlLJVIWzbwfLUUlAMIszhPbIaPasfkXc0jU+xMNGqk6PEMmZlXJw4ZXOCEtj57XACByGTGBw== X-Received: by 2002:a05:6a20:3d84:b0:1c3:b102:bfd2 with SMTP id adf61e73a8af0-1c3b102c10emr3668059637.14.1720707601607; Thu, 11 Jul 2024 07:20: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 Subject: [PATCH 16/18] ppc/pnv: Add big-core machine property Date: Fri, 12 Jul 2024 00:18:48 +1000 Message-ID: <20240711141851.406677-17-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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::432; envelope-from=npiggin@gmail.com; helo=mail-pf1-x432.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: 1720707628504116600 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 Tested-by: C=C3=A9dric Le Goater --- hw/ppc/pnv.c | 61 ++++++++++++++++++++++++++++++++++------------- hw/ppc/pnv_core.c | 6 +++-- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index efc9cf2cc3..575f18958d 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2577,6 +2577,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); @@ -2628,6 +2656,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) @@ -2664,6 +2698,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) @@ -2676,22 +2721,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 68cc5914c6..e03ac5441e 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -280,7 +280,8 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) PnvCore *pc =3D PNV_CORE(OBJECT(dev)); PnvCoreClass *pcc =3D PNV_CORE_GET_CLASS(pc); CPUCore *cc =3D CPU_CORE(OBJECT(dev)); - PnvMachineClass *pmc =3D PNV_MACHINE_GET_CLASS(pc->chip->pnv_machine); + PnvMachineState *pnv =3D pc->chip->pnv_machine; + PnvMachineClass *pmc =3D PNV_MACHINE_GET_CLASS(pnv); const char *typename =3D pnv_core_cpu_typename(pc); Error *local_err =3D NULL; void *obj; @@ -289,6 +290,7 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) =20 assert(pc->chip); =20 + pc->big_core =3D pnv->big_core; pc->tod_state.big_core_quirk =3D pmc->quirk_tb_big_core; =20 pc->threads =3D g_new(PowerPCCPU *, cc->nr_threads); @@ -299,7 +301,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 19:05:44 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=1720707761; cv=none; d=zohomail.com; s=zohoarc; b=cIk+p4a7MVk7F8tJAXEKdhdwWNh/e3fKTUiQutqJE09DPcjccmTF6HXdbFIcBFgexeg+XVTlf+WYeMfM5DVhe/LRDjvX9hUliQpYsBRQH91d6yaAWfzYk3pIVsLs27HYQHc5Q/Ipdgy9WzfyMdNOjvmiNWEWo600+FkLE0rXmWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707761; 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=puAh8AKYBf/kGCM5eTy9qpxHcT0Dr7J5AOeGF/jG3KU=; b=kuODiJ5GNkSNpdOsYy9KzYMJaAOu/TjKlxTUpXmh+zz0l6OdRPsxXo4JbiwUW6BZdToRmq3N2o7uP4KA79pzpX/iUGCvEkXjGihVId2mbepvIADVircB0ffZRs3BBMYN+vVJNjzOKcvPcoFPO7A+XEtbcBp4EWzBXKLC+MNCNho= 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 1720707761142600.8548041381035; Thu, 11 Jul 2024 07:22:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRueq-0000zG-Co; Thu, 11 Jul 2024 10:20:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRuem-0000aj-Lh; Thu, 11 Jul 2024 10:20:24 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRueV-0005l5-U2; Thu, 11 Jul 2024 10:20:24 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-70b4267ccfcso860154b3a.3; Thu, 11 Jul 2024 07:20:07 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.20.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707605; x=1721312405; 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=puAh8AKYBf/kGCM5eTy9qpxHcT0Dr7J5AOeGF/jG3KU=; b=lOmlJKmcak+KypOBR4qOYhoSIB/Qfl4VtwEcvXsjTX5h2slmAMDQ91XITQ0fNJEC6a u2aLBhL2Wx4TJ+o7ekJgO9HfJQnXDy8tufcdt/y1SUM7LN3jkHT2tJS8T0uwFpzIiFyf f6JbAzORuxGQC8h1TH4zOaDKjz8GIrrTDDmvPTHDVifoCXvmTf6jGtDD+KhTk0Jd+LBn XtopgZsuzadNfVFk5uadabgCwnaPDuXXZv50YttQ2X0V5w3ZKbNpP0pVpXrDnLP7DGwr yM5BYFyah2bt1QwW3idjOitiJ3Q2++iWDuMv38leJ87QtJ2NirJmEhd5tsK9ncEFff3m 4sAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707605; x=1721312405; 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=puAh8AKYBf/kGCM5eTy9qpxHcT0Dr7J5AOeGF/jG3KU=; b=n7i+8GT2VxVbXsDf4MuSBuB+l9/XB5i0Hq9XkJcMRjQbUSAwsGK6QDJX69VmKF88vu 5HYpkh58Gd3EzKlqjfGDOZZKuttUGqrlTCFT8BpDteH2zLKG8KRfuJgEwZ4oQb2WMQxT 1BLMogMriqCIgvYK3r9Y6asUVo8tEwREkTXOIT93ZmoqJ1tGQJgQd3c8L9eBdDPJStrm D09iqIu3Cpqja6+YfTkKwMaT4tytb6rCw4OtxD++U7nfgt48J2LzWGHXJ/u2hGLvp5d9 odVjmCbvy5BSLhSAIK73i2jBjZ8O2D9qDpE0cgT+3/qRtl8HtjZqSmDydT57dRNeAYxg riuQ== X-Forwarded-Encrypted: i=1; AJvYcCWM+e1Ck2ycdkg8B8nZiGNJ5D4XH/L/2WkvlJXPI+F6LN9Qf3zmVLgRtXTRAf4jd1hL2n7W/MwXetikXnvI/QGQ7sxr3nE= X-Gm-Message-State: AOJu0YwYQ4VCPbmxX17/gzT8/0VGx419Rt7tJw3IZFSwU1FkfEhrSUiW zTTKPGIkzSSRCPgpFmXQa1MFuxkLI7Y4VaxVzwSUXFarFsOQI6C41C0BepJo X-Google-Smtp-Source: AGHT+IFMKA7tZ5qDKUtNRAHXbPiklf/iIerMRuWnFHR9EGTee/JqCdLXThrWqJjIAuUEQ8unbJnnNA== X-Received: by 2002:a05:6a00:b45:b0:705:a450:a9a2 with SMTP id d2e1a72fcca58-70b435561ebmr10320089b3a.13.1720707605256; Thu, 11 Jul 2024 07:20: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 17/18] ppc/pnv: Implement POWER10 PC xscom registers for direct controls Date: Fri, 12 Jul 2024 00:18:49 +1000 Message-ID: <20240711141851.406677-18-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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::433; envelope-from=npiggin@gmail.com; helo=mail-pf1-x433.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: 1720707763185116600 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 OPAL (skiboot) firmware use, which is to stop threads and send them non-maskable IPIs in the form of SRESET interrupts. POWER10 is sufficiently different (particularly QME and special wakeup) from POWER9 that it is not trivial to implement by reusing the code. Signed-off-by: Nicholas Piggin Tested-by: C=C3=A9dric Le Goater --- include/hw/core/cpu.h | 8 ++++ include/hw/ppc/pnv.h | 2 + include/hw/ppc/pnv_core.h | 3 ++ hw/ppc/pnv.c | 19 +++++++-- hw/ppc/pnv_core.c | 88 ++++++++++++++++++++++++++++++++++++--- system/cpus.c | 10 +++++ 6 files changed, 122 insertions(+), 8 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index a2c8536943..410e7d6f03 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. + * + * Resumes CPU, i.e. puts CPU into stopped state. + */ +void cpu_pause(CPUState *cpu); + /** * cpu_resume: * @cpu: The CPU to resume. 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/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.c b/hw/ppc/pnv.c index 575f18958d..71b2b3806c 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2747,11 +2747,24 @@ 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) { + cpu_resume(cs); + } +} + +static void pnv_cpu_do_nmi(CPUState *cs, int resume) +{ + async_run_on_cpu(cs, pnv_cpu_do_nmi_on_cpu, RUN_ON_CPU_HOST_INT(resume= )); +} + +void pnv_cpu_do_nmi_resume(CPUState *cs) +{ + pnv_cpu_do_nmi(cs, 1); } =20 -static void pnv_cpu_do_nmi(PnvChip *chip, PowerPCCPU *cpu, void *opaque) +static void do_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); + pnv_cpu_do_nmi(CPU(cpu), 0); } =20 static void pnv_nmi(NMIState *n, int cpu_index, Error **errp) @@ -2760,7 +2773,7 @@ static void pnv_nmi(NMIState *n, int cpu_index, Error= **errp) int i; =20 for (i =3D 0; i < pnv->num_chips; i++) { - pnv_chip_foreach_cpu(pnv->chips[i], pnv_cpu_do_nmi, NULL); + pnv_chip_foreach_cpu(pnv->chips[i], do_pnv_cpu_do_nmi, NULL); } } =20 diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index e03ac5441e..a685a5dc1b 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,45 @@ 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); @@ -528,6 +588,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 @@ -535,10 +596,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); @@ -550,9 +615,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); diff --git a/system/cpus.c b/system/cpus.c index d3640c9503..083abbc393 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -613,6 +613,16 @@ void pause_all_vcpus(void) bql_lock(); } =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; --=20 2.45.1 From nobody Sun Nov 24 19:05:44 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=1720707758; cv=none; d=zohomail.com; s=zohoarc; b=R6Triy7cPYbldlv518SPcXzUrE6FlHCkNmyVU6SjmTm17cnRBicb7NU2C7gynhF2pmKtYO2W2HoWOEEoQ7+4SWVmKBfIp+yYfGFh/vQyG2VpuO6Ra7M3mCu8EUOHeRzhhCm2NjzbLcL6aNJ46RtUjotaY24Dd2B2bCSwa//ie9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720707758; 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=NvM5PCjcgATmFDUmIdzZ0Y+Hp3eStA1GkIR3w102lcM=; b=b+c17NKcNHJ0tkgDD4CybK6rq0CHivg63kHhUlA4kR4jBhwHRTF2XfbqKx5GRJdUQ4NB9UuV5/vRQREQVXq39PizkDkRN4pltjX5Q9gfFQ2A1qmHotPPaR+iu2fnkYlQ+9QaiDqIIf8p5AsfKnmzBX4o0lPwUUQqe0p4/bCgcLk= 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 1720707758809455.9864288285802; Thu, 11 Jul 2024 07:22:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRueo-0000rr-Lk; Thu, 11 Jul 2024 10:20:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRuek-0000Dv-7C; Thu, 11 Jul 2024 10:20:23 -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 1sRued-0005lV-UO; Thu, 11 Jul 2024 10:20:21 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-70af8128081so779324b3a.1; Thu, 11 Jul 2024 07:20:10 -0700 (PDT) Received: from wheely.local0.net ([203.220.44.216]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b54ec730fsm3308904b3a.173.2024.07.11.07.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 07:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720707609; x=1721312409; 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=NvM5PCjcgATmFDUmIdzZ0Y+Hp3eStA1GkIR3w102lcM=; b=C3nVSqHaNssCktb3BR4T9iz/6B65XCatLT/v4rn+26UHfqaD6BMVlyy3GcJblX80Ku 0ddsTJLioHvplXg7c1ELutCtB1tlTNQXhn2AoeoN07iBgbFjzbUEe/Gf0RA2pGPlAd8y poUEfkrMb+ds40E+KR68+3ej0IbyD+SAY00QlazidJLfE3RqjbSF5xQ8yS3oMg5PaFqy ZWLukY+SiEpnjbN8A3IjmHcB2I09GqiIlBRj8BFdPCx0N0fQdQPcDXbLquXhpFWvvc57 X1Adn9vZzfdU8sqHMqXsi01ZNDZHE4buQSUYf1/pW0b0waPDGyiT5wO2RrtpkyPz0Vui vh6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720707609; x=1721312409; 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=NvM5PCjcgATmFDUmIdzZ0Y+Hp3eStA1GkIR3w102lcM=; b=hk07JcFlVSTl7cta0eZUrgc2wzKmUFOQl124vKKx6SmhQxcdN8K9MleMi/LP0ltIR9 1f2Q02sQPxLQmFzYBD6ueBDZ+J4YFgNTujkNTF9HgDYJZmdpPrqPE22Bpow8fmcGeZ/0 M54Vxy1Pxdrwk2oL379+HF/XD1zY+B1UKWcFHnbUoNb16aF2FiHQOe67Sd0Fvbb2GLFU kh33JEI4OAcV9hVEMRJsyc+0XUF3ADakv1SzXJ4ag9TgKrzaqh9Mm7ay/wijedcfuzwe BTAHEc/DBH70KT/UFcosKEldASBpS74OkJIilHnc+BZd7mJlqUH/09/ziwUxVdEDFJkl 9/8A== X-Forwarded-Encrypted: i=1; AJvYcCVdhoK6SvGbH+N5nJ5bq06bRuNlFXEPLPA9/GoSX4Fvnio5Om2FttvMAY67djqIPZUcrEjuAlIMpzH8TJCR4mn8LW8dOWU= X-Gm-Message-State: AOJu0YxQOfBkUYfugmPJCRYV9RvJ4NhIXc5xQgpgJ+uUtSWT4+XlytBw GFjmbj4sQb2TKXzN1QHsbKOBnlb/t7hvhueb3oeNWVIs0CVrni18Zg+yPgTm X-Google-Smtp-Source: AGHT+IEdldM24IEBTKRKSN3sY0sFO+87U4USLJzbltP3QxeKmp/M/l8hEveLq1FndLGYeiZG12ZTnw== X-Received: by 2002:a05:6a20:729a:b0:1c0:f2a5:c8dc with SMTP id adf61e73a8af0-1c2984cfa6bmr9702789637.50.1720707609057; Thu, 11 Jul 2024 07:20: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 18/18] ppc/pnv: Add an LPAR per core machine option Date: Fri, 12 Jul 2024 00:18:50 +1000 Message-ID: <20240711141851.406677-19-npiggin@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240711141851.406677-1-npiggin@gmail.com> References: <20240711141851.406677-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::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: 1720707759133116600 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, including KVM. Signed-off-by: Nicholas Piggin Tested-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv.h | 1 + include/hw/ppc/pnv_core.h | 1 + hw/ppc/pnv.c | 29 +++++++++++++++++++++++++++++ hw/ppc/pnv_core.c | 8 ++++++++ target/ppc/cpu_init.c | 3 ++- 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index b7858d310d..73f0d72f55 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -104,6 +104,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_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 71b2b3806c..f9a05fa0ff 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1026,6 +1026,11 @@ static void pnv_init(MachineState *machine) exit(1); } =20 + if (!object_property_find(OBJECT(pnv), "lpar-per-core")) { + /* POWER8 is always in lpar-per-core mode */ + pnv->lpar_per_core =3D true; + } + pnv->num_chips =3D machine->smp.max_cpus / (machine->smp.cores * machine->smp.threads= ); =20 @@ -2589,6 +2594,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_1lpar(Object *obj, Error **errp) +{ + PnvMachineState *pnv =3D PNV_MACHINE(obj); + return pnv->lpar_per_core; +} + +static void pnv_machine_set_1lpar(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); @@ -2662,6 +2679,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_1lpar, + pnv_machine_set_1lpar); + 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) @@ -2709,6 +2732,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_1lpar, + pnv_machine_set_1lpar); + 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 a685a5dc1b..5a6fcb6edc 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; @@ -320,6 +323,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); } @@ -352,6 +359,7 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) =20 pc->big_core =3D pnv->big_core; pc->tod_state.big_core_quirk =3D pmc->quirk_tb_big_core; + pc->lpar_per_core =3D pc->chip->pnv_machine->lpar_per_core; =20 pc->threads =3D g_new(PowerPCCPU *, cc->nr_threads); for (i =3D 0; i < cc->nr_threads; i++) { diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 9349001b76..0fc83d5cc2 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6785,7 +6785,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